Making a simple maths game that takes a user input as an answer for the sum of two randomly generated numbers.
Each time i run it, i get 7+7, 2+2, 3+3 etc, but never two different numbers.
Any help would be much appreciated
public class Q3
public static void main (String  args)
double first = Math.random()*10;
int firstNumber = (int)first;
double second = Math.random()*10;
int secondNumber = (int)second;
String userAnswerString = JOptionPane.showInputDialog("What is the sum of: " + firstNumber + "+" + secondNumber + " ?");
double userAnswerDouble = Double.parseDouble(userAnswerString);
int answer = (int)userAnswerDouble;
if (answer == (firstNumber + secondNumber))
System.out.println("Congratulations! You are Correct!");
System.out.println("Sorry, that is wrong! The correct answer was: " + (firstNumber+secondNumber));