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