I want to generate random numbers, display them with ten in a row, and count how many are 1s, 2s, 3s, 4s, 5s, and 6s with nested if/else statement.
import java.util.Random;
public static void main(String [] args)
{
Random generator = new Random( );
int value = 0;
int numbers1 = 0;
int numbers2 = 0;
int numbers3 = 0;
int numbers4 = 0;
int numbers5 = 0;
int numbers6 = 0;
for (int counter=0; counter<20; counter++)
{
int value = generator.nextInt(6)+1;
System.out.print(" "+value);
if (counter % 10 == 0)
{
System.out.print();
}
}
}
Please identify any mistakes and help me with the counting of random numbers.