SuperTutor

(15)

$15/per page/Negotiable

About SuperTutor

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Business & Finance See all
Accounting,Business & Finance,Economics,Engineering,HR Management,Math Hide all
Teaching Since: Apr 2017
Last Sign in: 327 Weeks Ago, 5 Days Ago
Questions Answered: 12843
Tutorials Posted: 12834

Education

  • MBA, Ph.D in Management
    Harvard university
    Feb-1997 - Aug-2003

Experience

  • Professor
    Strayer University
    Jan-2007 - Present

Category > Programming Posted 18 May 2017 My Price 9.00

Mission #7CS 1400 - Hilton

Write a program that simulates the rolling of two 6-sided dice. Use an Array to keep track of the number of times that each total number is thrown. In other words, keep track of how many times the combination of the two simulated dice is 2, how many times the combination is 3, and so on,all the way up through 12. Allow the user to choose how many times the “dice” will be thrown. Then, once the dice have been thrown the specified number of times, print a histogram (using the * character) that shows the total percentage each number was rolled. Each * will represent 1% of the total rolls.

 

 

Mission #7CS 1400 - HiltonWrite a program that simulates the rolling of two 6-sided dice.Use an Array to keep track of thenumber of times that each total number is thrown.In other words, keep track of how many timesthe combination of the two simulated dice is 2, how many times the combination is 3, and so on,all the way up through 12.Allow the user to choose how many times the “dice” will be thrown.Then, once the dice havebeen thrown the specified number of times, print a histogram (using the * character) that showsthe total percentageeach number was rolled.Each * will represent 1% of the total rolls.Sample session:Welcome to the dice throwing simulator!How many dice rolls would you like to simulate? 1000DICE ROLLING SIMULATION RESULTSEach "*" represents 1% of the total number of rolls.Total number of rolls = 1000.2: ***3: ***4: ***********5: ***********6: ********7: ******************8: ****************9: **********10: *************11: *****12: **Thank you for using the dice throwing simulator.Goodbye!Submit your .java file containing the source code via WSU Online.

/******************** Week7Assignment.java* Taylor Hardy*******************/import java.util.Scanner;import java.util.Random;public class Week7Assignment{public static void main (String[] args){Scanner in = new Scanner(System.in);Random random = new Random();//Welcome UserSystem.out.println("Welcome to the dice throwing simulator!");//int neededint[] percent = new int[11];int times;int total;int totalIs2 = 0;int totalIs3 = 0;int totalIs4 = 0;int totalIs5 = 0;int totalIs6 = 0;int totalIs7 = 0;int totalIs8 = 0;int totalIs9 = 0;int totalIs10 = 0;int totalIs11 = 0;int totalIs12 = 0;//Ask user how many time they want to roll the diceSystem.out.println("How many dice rolls would you like to simulate?");times = in.nextInt();//Declare variables for die 1 and die 2int die1[] = new int[times];int die2[] = new int[times];//Create an array for each die rollint[] array = new int[times];for (int i = 1; i < array.length; i++ ){die1[i] = (int) ((Math.random() * 6) + 1);die2[i] = (int) ((Math.random() * 6) + 1);total = die1[i] + die2[i];//Count total of each numbered possibility rolledif (total == 2) {totalIs2++;}if (total == 3) {totalIs3++;}if (total == 4) {totalIs4++;

Attachments:

Answers

(15)
Status NEW Posted 18 May 2017 05:05 AM My Price 9.00

-----------

Not Rated(0)