import javax.swing.JOptionPane;
public class RandomNumbers {
public static void main (String[] args) {
//Generate three random numbers
int one, two, three;
one = (int)(Math.random()*(10));
two = (int)(Math.random()*(10));
three = (int)(Math.random()*(10));
//What is the sum of these numbers
String sumOfNumbersString =
JOptionPane.showInputDialog(null,"What is the sum of " + one + "+" +
two + "+" + three + "?");
//Convert string to int
int sumOfNumbers =Integer.parseInt(sumOfNumbersString);
//Check the answer and Display Results
if (one + two + three == sumOfNumbers)
JOptionPane.showMessageDialog(null, "You are Correct!");
else
JOptionPane.showMessageDialog(null, "Sorry, that is Incorrect \n" +
one + "+" + two + "+" + three + " equals " + (one + two + three));
}
}