Please help I am trying to get x below to equal the sum of the first two random integers and not integers 3 and 4. But the program doesn't add togetehr -7 and 12 but instead adds together later random integers that are created to get an answer of 14. What do I need to do? Thanks for any assistance. This is my first time using JAVA and I am struggling.
int rand_int1 = -rand.nextInt(20);
int rand_int2 = rand.nextInt(20);
x = (-rand.nextInt(20) + rand.nextInt(20));
System.out.println("Answer is: "+x);
System.out.println("Add this number: "+rand_int1);
System.out.println("and this number together: "+rand_int2);
Answer is: 14
Add this number: -7
and this number together: 12
BUILD SUCCESSFUL (total time: 0 seconds)
The program will be used to create 20 random integers once it is fully written but I am not able to get the first random numbers to be used in the program.