Hi guys! I have created a program that is designed to ask students multiple equation questions. The program will only be designed to ask single digit numbers. I have managed to create the questions and a random number generator, but i want this program to constantly loop, any ideas on how to implement a loop?
Heres my code:
import java.util.Scanner; public class SubtractionQuiz { public static void main (String[] args) { int number1 = (int) (Math.random() * 10); int number2 = (int) (Math.random() * 10); System.out.println("What is" + number1 + " * " + number2 + "?"); Scanner input = new Scanner(System.in); int answer = input.nextInt(); if (number1 * number2 == answer) System.out.println("You are correct!"); else System.out.println("Wrong!"); } }
Thanks in advance!