PSEUDOCODE HELP Create the logic for an application that contains an array of 10
ID: 3779417 • Letter: P
Question
PSEUDOCODE HELP
Create the logic for an application that contains an array of 10 multiple-choice questions related to your favorite hobby. Each question contains three answer choices. Also create a parallel array that holds the correct answer to each question—A, B, or C. Display each question and verify that the user enters only A, B, or C as the answer—if not, keep prompting the user until a valid response is entered. If the user responds to a question correctly, display Correct!; otherwise, display The correct answer is and the letter of the correct answer. After the user answers all the questions, display the number of correct and incorrect answers.
Explanation / Answer
public class hobby
{
public static void main(String[] args) throws Exception
{
char[] correctAns = {'A', 'B' , 'C', 'D', 'A', 'B', 'C', 'D', 'A', 'B' };
char[]Ans =new char [10];
int x, tot = 0;
char ans;
System.out.println("The following are my hobbies");
do { tot =0;
for (x=0; X<hobbies.length; ++x)
{
System.out.print(:enter your hobbie"+(x+1)+" ");
ans[x] = (char)System.in.read();
System.in.skip(System.in.available());
ans[x] = Character.toUpperCase(Ans[x]);
if( Ans[x] == correctAns[x])
tot =tot+1;
}
System.out.println("you are" + tot+"right and" +(10-tot) + "wrong");
System.out.println("do you want try again? ( 'Y 'or 'N' )" );
Ans =(char)System.in.read();
System.in.skip(System.in.available(0);
}
whole Aans == 'y' | | Ans =='Y' );
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.