import java.util.*;
public class Addition {
public static void main (String[]args) {
Scanner sc = new Scanner (System.in);
int choice = 0;
while (choice<3) {
System.out.println("Menu:");
System.out.println("1. Enter a number to practice");
System.out.println("2. Practice with a random number");
System.out.println("3. Quit");
System.out.print("Your choice: ");
choice = sc.nextInt();
int addNum = 0;
if (choice == 1) {
//Prompt user for the number to practice on
System.out.print("\nEnter a number to practice: ");
addNum = sc.nextInt();
}
else if (choice == 2) {
Random number = new Random();
addNum = number.nextInt(10)+1;
System.out.print("\nYou will be quizzed on: " +addNum +"\n");
}
int score = 0;
for (int num=1; num<=10; num++){
System.out.print(num +" X " +addNum +" = ");
int userInput = sc.nextInt();
int addAns = num*addNum;
if (addAns == userInput) {
System.out.print("Correct!\n");
score++;
}
else {
System.out.print("Wrong!\n");
}
}
System.out.print("Your score: " +score +"/10\n\n");
}
}
}