dimanche 17 février 2019

Generating 10 random numbers in a for loop between 1 and 50 in java

I need to create a program in Java that will generate 10 random numbers between 1 and 50 and output them using a for loop. I have figured out how to generate the random numbers, but cant figure out how to do it using a for loop. Please help!

import java.util.Random;
class RandomNumbers
{
public static void main (String [] args)
{
int random = (int)(Math.random()* (50 + 1));
System.out.println (random);
}

}




Aucun commentaire:

Enregistrer un commentaire