Java histogram from random generated numbers

Hi guys, I am playing with and learning a bit of java, so I'm really a newbie ... My problem is - I am generating 5 random numbers from 1 to 5. My program then calculates how many times are number 1, number 2, number 3, number 4 and number 5 generated within these randoms.

public static void main(String[] args) {

Random rand = new Random();

int[] array = new int[5];

int randomNumber;

int i;

int p1 = 0;

int p2 = 0;

int p3 = 0;

int p4 = 0;

int p5 = 0;

System.out.println("Random numbers:");

for (i = 0;...

Read More »

By: StackOverFlow - Tuesday, 20 November

Related Posts