I am a very beginner (5 days) and I am trying to make a program that generates frequency on whatever sided dice you want. I dont want to know how to make it more efficient. Just what I did wrong. Here's the code:
import java.util.Scanner; import java.util.Random; public class dieRoll { public static void main(String[] args) { Scanner input = new Scanner(System.in); Random rand = new Random(); System.out.println("Type number of sides on die: "); int faces = input.nextInt(); int freq[] = new int[1 + faces]; for(int roll = 1; roll < 1000; roll++) { ++freq[1 + rand.nextInt(faces)]; } System.out.println("Face\tFrequency"); for(int side = 1; side < freq.length; side++); { System.out.println(side+ "\t" + freq[side]); } } }
And here's the problem:
the problem is the last print line.