Maurice Tutor

(5)

$15/per page/Negotiable

About Maurice Tutor

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

Expertise:
Algebra,Applied Sciences See all
Algebra,Applied Sciences,Biology,Calculus,Chemistry,Economics,English,Essay writing,Geography,Geology,Health & Medical,Physics,Science Hide all
Teaching Since: May 2017
Last Sign in: 398 Weeks Ago, 5 Days Ago
Questions Answered: 66690
Tutorials Posted: 66688

Education

  • MCS,PHD
    Argosy University/ Phoniex University/
    Nov-2005 - Oct-2011

Experience

  • Professor
    Phoniex University
    Oct-2001 - Nov-2016

Category > Computer Science Posted 14 Sep 2017 My Price 6.00

experiment rolls

Ask the user for a number, call it n

? Run n experiments, where each experiment rolls 4 dice and adds them up

? Keeps track of the total of the 4 dice in each experiment

? Prints out the histogram showing how many times each total occurred (so in total it should print out n of the X symbols)

This is what I have so far but I don't know what to do next.

#include <iostream>

#include <cstdlib>

#include <ctime>

void printHistogram(int counts[])

{

for (int i = 4; i <= 24; i++)

{

std::cout << i << ":";

  

for (int j = 0; j < counts[i]; j++)

{

std::cout << "X";

}

  

std::cout << std::endl;

}

}

int rollDice (int n)

{

int rollDice1;

int rollDice2;

int rollDice3;

int rollDice4;

int sumDice;

srand(time(0));

for (int runN = 0; runN <= n; runN++)

{

for (int startDice = 0; startDice < n; startDice++)

{

rollDice1 = rand() % 6 + 1;

rollDice2 = rand() % 6 + 1;

rollDice3 = rand() % 6 + 1;

rollDice4 = rand() % 6 + 1;

sumDice = rollDice1 + rollDice2 + rollDice3 + rollDice4;

}

}

}

int main()

{

int n;

std::cout << "Enter a Number n:";

std::cin >> n;

int testCounts[24]; // more than enough space

for (int i = 4; i <= 24; i++)

rollDice(n);

testCounts[i] = rollDice(n); // fill array

printHistogram(testCounts); // Call your method

}

Answers

(5)
Status NEW Posted 14 Sep 2017 07:09 PM My Price 6.00

Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll

Not Rated(0)