Am trying to do a question with no luck. This is the question that I am trying to do.
A) Write a program that displays a multiple choice quiz of 10 questions. Each question has one correct answer and three possible answers. Verify that the user enters only A, B, or C. as the answer. Store the correct answers in an array. Store the user's answers in a second array. If the user responds to a question correctly, display "Correct"; otherwise display "The correct answer is" and the letter of the correct answer. Determine what to display by comparing the response to the array of correct answers.
B) Modify the quiz class so that it displays the number of correct answers after the user answers 10 questions. Determine the score by comparing the two arrays.
This is what I have done so far:
/*package assignment4;
public class Quiz
{
public static void main(
String[] args)throws Exception
{
char [] correctAns= {'A','B','C','D','A','B','C','D','A','B'};
char []stuAns = new char [10];
int x, tot = 0;
char ans;
System.out.println ("The following
test has 10 multiple choice questions");
do
{ tot = 0;
for (x = 0; x< stuAns.length; ++x)
{
System.out.print ("Enter your answer for question " + (x+1)+ " ");
stuAns[x] = (char)System.in.read();
System.in.skip(System.in.available());
stuAns[x] = Character.toUpperCase(stuAns[x]);
if ( stuAns[x] == correctAns[x])
tot = tot + 1;
}
System.out.println ("You got " + tot +" right and " + (10 - tot) + " wrong");
System.out.println ("Do you want to try again ? ( 'Y' or 'N') ");
ans = (char)System.in.read();
System.in.skip(System.in.available());
} while (ans == 'y' || ans =='Y') ;
}
}*/
Am I on the right track here.
I don't know how to get my question in there any where.
Any help that you could give me would be greatly appreciated.
thanks