I am a beginner and I am trying to create a quiz to ask the user 3 Questions, I created 2 arrays: one for the questions and one for the right answer:
public static void main (String[] param) {
String QArray[] = new String[3];
QArray[0] = "What is 5 x 10?";
QArray[1] = "What is 10 x 12?";
QArray[2] = "What about 10 x 10?";
String AArray[] = new String[3];
AArray[0] = "50";
AArray[1] = "120";
AArray[2] = "100";
...
}
In order to make it work:
for (int n = 0; n < QArray.length; n++) {
System.out.println("Question" + (n + 1));
System.out.println((QArray[n]));
for (int m = 0; m < 3; m++) {
String ans = scanner.nextLine();
if (ans.equalsIgnoreCase(AArray[n])) {
System.out.println("You got it right!");
break;
} else {
System.out.println("\nThat is incorrect!");
}
}
}
However I need to include getters and setters for my code, how could I include getters and setters with arrays? What do I need to replace it with?