Need project help
Hey guys. I'm in a Java class and I have NO CLUE what I am doing. I have a project that is a Dice Simulator. We have to write a program that simulates User-specified number of rolls and then prints a histogram of the number of rolls for each pair value, i.e. the number of times a 2 was thrown, 3 was thrown, etc. We have to use a frequency array. I do not understand how to do this. Can someone please help me. I mean, I also had to do a driver class which I have some of it completed not all, so if you need me to post that I can. I'm still working on that part of it but I am figuring it out slowly. However, I am completely at a loss on this other part. Any help/advice would be greatly appreciated.
A frequency array is simply going to be an array where the index is the value and the value stored at the index is the number of times that value has occured. For instance,
So, in your program when you roll a number you do something like this:
int frequencies = new int;
frequencies; // represents the number of times a 1 was rolled
frequencies; // represents the number of times a 2 was rolled
frequencies; // represents the number of times a 3 was rolled
Hope this helps.
int rollValue = Die.roll(); // or however you are getting the value fo the roll
frequencies[rollValue-1]++; // increment the number of times that the value showed up.
By Gary Nelson in forum .NET
Last Post: 10-01-2003, 01:00 AM
By Robert G in forum .NET
Last Post: 02-08-2001, 03:38 PM
By Todd B - Agendum Software in forum vb.announcements
Last Post: 09-13-2000, 11:18 AM
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center