Create a class Book with the following private member variables. Include appropriate getters and setters method. Create a class TestBook which has the main method. Get the details as shown in the sample input. Create an object for book class and assign the value for its attrbutes using the setters. Now your tests just print a '.' If they work, but give you a neat report if they fail. One note, see how I had to turn the double result into a string with '+method. That's a little kludgey and a bit hard to predict. You might prefer another assertEquals method that takes two doubles as arguments.
A simple way you can achieve this would be to have a while-loop inside the main loop of your quiz code which checks your input variable value.
You would set the initial value of the variable that holds the value of the users input to a default string and check to make sure that you keep asking the user for an input while the value of that input is not equal to your desired inputs of: ['D', 'C', 'B', 'A']
You can achieve this using the logical '&&' (and) operator to check and make sure that if the input is not equal to any of the acceptable input you continue looping for an input. This way each time the user inputs a value, the program does not move on until it sees a recognized input.
Specifically in pseudo-code you would write this:
user_ans[i] = ';
user_ans[i] = USER_INPUT
} while(user_ans[i] != 'D' && user_ans[i] != 'C' && user_ans[i] != 'B' && user_ans[i] != 'A');
Create A Quiz Program In Java
How To Program In Java
} while ()