Write an application that contains an array of 10 multiple-choice quiz questions related to your favorite hobby. Each question contains three answer choices. Also create an 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 here is my new code! i need help to get it to working : import java.util.*; public class Quiz { public static void main(String args[]) { String questions[]=("1.What is my favorite hobby?\n" + "(a)hair\n(b)makeup\n(c)both a and b\n", "2.Who first discovered makeup?\n" +"(a)Egyptians\n(b)haitians\n(c)Africans", "3.What glue is best to use when laying down a frontal?\n" + "(a)ghostbond\n(b)boldHold\n(c)Got2b\n" , "4.How many layers of glue do you need before applying a wig onto your head?\n" + "(a)3\n(b)4\n(c)1\n", "5.Always get a shade lighter than your skin when using\n" + "(a)contour\n(b)concealer\n(c)foundation\n", "6.What type of makeup brush would you use to blend your foundation?\n" + "(a)powder brush\n(b)body brush\n(c)neither\n", "7.How long do you suppose to keep a lace front wig installment in your head?\n" + "(a)4 weeks\n(b)2-3 weeks\n(c)5 weeks\n", "8.What do you use to remove makeup off your face?\n" + "(a)baby wipes\n(b)Neutrogena Cleansing towlettes\n(c)clorox wipes\n", "9.What is the BEST way to remove lace glue from your hair?\n" + "(a)alcohol\n(b)shampoo\n(c)water\n", "10.When did the early Egyptians contrust their first wig?\n" + "(a)2700 B.C.E\n(b)2400 B.C.E\n(c)2500 B.C.E\n"); int i,j,c = 0; char quest_answers[]= {"c","a","a","a","b","c","b","b","a","a"}; char answers; Scanner input = new Scanner(System.in); for(i=0; i<10; i++) { System.out.println(questions[i]); System.out.println("A.true"); System.out.println("b.false"); answers = input.nextLine().charAt(0); if(answers==quest_answers[i]) { System.out.println("Correct"); c++; } else { System.out.println("the correct answer is" + quest_answers[i]); } } System.out.println("Number of correct answers are" +c); } }
this practice assignement wants me to Write an application that contains an array of 10 multiple-choice quiz questions related to your favorite hobby. Each question contains three answer choices. Also create an 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
here is my new code! i need help to get it to working :
import java.util.*;
public class Quiz {
public static void main(String args[])
{
String questions[]=("1.What is my favorite hobby?\n" + "(a)hair\n(b)makeup\n(c)both a and b\n", "2.Who first discovered makeup?\n" +"(a)Egyptians\n(b)haitians\n(c)Africans", "3.What glue is best to use when laying down a frontal?\n" + "(a)ghostbond\n(b)boldHold\n(c)Got2b\n" , "4.How many layers of glue do you need before applying a wig onto your head?\n" + "(a)3\n(b)4\n(c)1\n", "5.Always get a shade lighter than your skin when using\n" + "(a)contour\n(b)concealer\n(c)foundation\n", "6.What type of makeup brush would you use to blend your foundation?\n" + "(a)powder brush\n(b)body brush\n(c)neither\n", "7.How long do you suppose to keep a lace front wig installment in your head?\n" + "(a)4 weeks\n(b)2-3 weeks\n(c)5 weeks\n", "8.What do you use to remove makeup off your face?\n" + "(a)baby wipes\n(b)Neutrogena Cleansing towlettes\n(c)clorox wipes\n", "9.What is the BEST way to remove lace glue from your hair?\n" + "(a)alcohol\n(b)shampoo\n(c)water\n", "10.When did the early Egyptians contrust their first wig?\n" + "(a)2700 B.C.E\n(b)2400 B.C.E\n(c)2500 B.C.E\n");
int i,j,c = 0;
char quest_answers[]= {"c","a","a","a","b","c","b","b","a","a"};
char answers;
Scanner input = new Scanner(System.in);
for(i=0; i<10; i++)
{
System.out.println(questions[i]);
System.out.println("A.true");
System.out.println("b.false");
answers = input.nextLine().charAt(0);
if(answers==quest_answers[i])
{
System.out.println("Correct");
c++;
}
else
{
System.out.println("the correct answer is" + quest_answers[i]);
}
}
System.out.println("Number of correct answers are" +c);
}
}
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images