Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Netbeans Question need help desperately!!
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Sarah Love
Netbeans Question need help desperately!!
0 Answer(s)      4 years ago
Posted in : Java Beginners


Ok here is my code-

public class RollDie2 {


public static void main(String[] args) {

    Random randomNumber = new Random();

int[][] frequency = new int[9][9];
int die1 = 0;
int die2 = 0;


for (int roll = 1; roll <= 64000; roll++) {
die1 = randomNumber.nextInt(8) + 1;
die2 = randomNumber.nextInt(8) + 1;
frequency[die1][die2] = frequency[die1][die2] + 1;
frequency[die2][die1] = frequency[die2][die1] + 1;
}
System.out.printf("%5s%10s%15s\n", " Number", "Number", " Frequency");
for (int number = 0; number <= 16; number++) {
System.out.printf("%4d%10d\n", number, number, number, frequency[die1][die2] + 1);

okay that's the code....I'm trying to get a two-dimensional array to tally the actual combinations of rolls on 8 sided dice. How do I get the frequency of the numbers to print?


Advertisement
View Answers

Related Tutorials/Questions & Answers:
Advertisements
 

 

 

DMCA.com