(Addition quiz) Rewrite Listing 1 RepeatAdditionQuiz.java to alert the user if an answer is entered again. Hint: use an array list to store answers. Here is a sample run:

LISTING 1 RepeatAdditionQuiz.java
1 import java.util.Scanner;
2
3 public class RepeatAdditionQuiz {
4 public static void main(String[] args) {
5 int number1 = (int)(Math.random() * 10);
6 int number2 = (int)(Math.random() * 10);
7
8 // Create a Scanner
9 Scanner input = new Scanner(System.in);
10
11 System.out.print(
12 "What is " + number1 + " + " + number2 + "? ");
13 int answer = input.nextInt();
14
15 while (number1 + number2 != answer) {
16 System.out.print("Wrong answer. Try again. What is "
17 + number1 + " + " + number2 + "? ");
18 answer = input.nextInt();
19 }
20
21 System.out.println("You got it!");
22 }
23 }
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.