Win a copy of Serverless Applications with Node.js this week in the NodeJS forum!

since Apr 07, 2019

Cows and Likes

Cows

Total received

0

In last 30 days

0

Total given

0

Likes

Total received

0

Received in last 30 days

0

Total given

0

Given in last 30 days

0

Forums and Threads

Scavenger Hunt

Ranch Hand Scavenger Hunt

Greenhorn Scavenger Hunt

Campbell Thanks I will look through the material..

2 weeks ago

Gerard Thank you for your help with this.

2 weeks ago

Thank you for your reply showing how to get 20 random integers in the array. How though can I refer to each integer in the array so I can do separate calculations on each pair of integers?

2 weeks ago

I assume you mean I call it four times as I use four numbers. If I just want to add 2 numbers together then I assume that I just use rand.nextInt(2)

Could I then loop through 5 times to get 20 numbers?

Could I then loop through 5 times to get 20 numbers?

2 weeks ago

I am later using this to produce 20 random numbers but first want to do calculations with each pair of random numbers.

2 weeks ago

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);

int x;

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);

run:

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.

int rand_int1 = -rand.nextInt(20);

int rand_int2 = rand.nextInt(20);

int x;

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);

run:

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.

2 weeks ago