This is what i have so far. Im suppoed to simulate the 4 dice tossed 1 million t
ID: 3539320 • Letter: T
Question
This is what i have so far. Im suppoed to simulate the 4 dice tossed 1 million times . (so a total of 4 million) Im trying to get the first die(If I can figure out the first one then I can figure out the other 3. So the trouble im having is that I cant get the face in the output to show the numbers I appointed in the first array die1. How do I get the numbers for die1 to show on the output. Also the frequency is way over the 1 million. How do I get it so that my frequency to stay in the 1 million range (or any other number that the user may input. Really need help for this. Its due tomorrow but ive been working hard at this for the past week. Help would be appreciated! Thank you
(just to let you know the pic cut off at 10, it goes on to 12 for the face on the output)
Explanation / Answer
//PLEASE READ THE HIGHLIGHTED BOLD COMMENTS import java.util.Random; import java.util.Scanner; public class Game_Of_Dice { public static void main(String[] args) { Scanner input = new Scanner(System.in); Random rand = new Random(); int[] die1= {1,8,11,14,19,22,27,30,35,38,41,48}; //This sets up the array for each of the die. int[] die2 = {2,7,10,15,15,23,26,31,34,39,42,47};//Goes from 0-11 in each of the die. int[] die3 = {3,6,12,13,17,24,25,32,36,37,43,46}; int[] die4 = {4,5,9,16,20,21,28,29,33,40,44,45}; int temp, times; //you need a count die for each to store the frequency. int[] freqDie1=new int[12]; int[] freqDie2=new int[12]; int[] freqDie3=new int[12]; int[] freqDie4=new int[12]; System.out.println("We will simulate rolling 4 different dice."); System.out.println("This will test the hypothesis of the 'go first dice' "); System.out.println("We will now roll the first die one million times. Please enter the number one million."); times = input.nextInt(); for(int i=0;iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.