how to get this set of code right (while, if, else)
hi, the above is the code i write. it's a simple math question. it should loop as long as the answer isn't correct.
import java.util.Scanner; // Make the Scanner class available.
public class test
public static void main(String args)
int number1 = (int)(100 * Math.random()) + 1;
int number2 = (int)(100 * Math.random()) + 1;
System.out.println ("This is a addition maths program");
System.out.println (number1 + "+" + number2);
Scanner stdin = new Scanner( System.in ); // Create the Scanner.
System.out.println ("What's your answer?: ");
answer = stdin.nextInt(); //to react with the user input
//this is for the loop, as long as the input is incorrect
while (answer = None)
if (answer == (number1 + number2))
System.out.println ("You are correct");
System.out.println ("The sum is " + (number1 + number2));
System.out.println ("Your answer is incorrect, please try again");
can anyone point out the correct way?