I'm working on code for an assignment and I was hoping you all could point me in the right direction.
Basically I had to write a program that will issue out a multiple choice test. I have 4 options, A, B, C, D and if the user accidentally chooses something other than my options I want it to ask the question over again.
I've messed around with loops and counters but I'm really hitting a standstill right here. I seem to be unable to get this to work so I'd like you to review my code as is. The code at it's current state here is working, although it does not do much.
I'm up for whatever critique, so if you see something a beginning Java student should do, please let me know.
public static void main(String[] args) {
String[] multiChoice1;
Scanner input = new Scanner(System.in);
multiChoice1 = new String[5];
multiChoice1[0] = "1. Which country currently emits the most greenhouse gases?\n";
multiChoice1[1] = "blah blah";
multiChoice1[2] = "blah blah";
multiChoice1[3] = "blah blah";
multiChoice1[4] = "blah blah";
String userSelect1 = multiChoice1[0];
if(userSelect1==multiChoice1[0]){
System.out.println(multiChoice1[0]);
System.out.println("A. United States");
System.out.println("B. China");
System.out.println("C. India");
System.out.println("D. England");
System.out.println();
System.out.print("Your answer: ");
String uSelect1 = input.next();
switch (uSelect1.toUpperCase()){
case "A":
uSelect1 = "United States";
System.out.println("Incorrect!\n\n");
break;
case "B":
uSelect1 = "China";
System.out.println("Correct!\n\n");
scorePro++;
score++;
break;
case "C":
uSelect1 = "India";
System.out.println("Incorrect!\n\n");
break;
case "D":
uSelect1 = "England";
System.out.println("Incorrect!\n\n");
break;
default:
uSelect1 = "Incorrect, choice.\n\n";
break;
}
}
// more multiple choice questions with similar structure
}