Create a C program that simulate rolling a die 100 times The

Create a C++ program that simulate rolling a die 100 times. The program displays the tally of the how many times for each number. For example: 16 times 20 times Create a C++ program that prompts the user to enter a selected number for Taco Bell lunch menu. The program displays the name and price of the item based on the number entered by the user. The

Solution

#include <iostream>

#include <cstdlib>

#include <ctime>

#include <iomanip>

using namespace std;

int main()

{

    srand ((unsigned int)time(0));

    int times_rolled;

    int rolled;

    int num1 = 0;

    int num2 = 0;

    int num3 = 0;

    int num4 = 0;

    int num5 = 0;

    int num6 = 0;

    cout <<\"How many times would you like to roll the dice?\" << endl;

    cin >> times_rolled;

     

        for (int i = 0; i < times_rolled; ++i)

        {

            rolled = rand() % 6 + 1;

         

            if (rolled = 1)

            {

                num1++;

            }

            else if (rolled = 2)

            {

                num2++;

            }

            else if (rolled = 3)

            {

                num3++;

            }

            else if (rolled = 4)

            {

                num4++;

            }

            else if (rolled = 5)

            {

                num5++;

            }

            else if (rolled = 6)

            {

                num6++;

            }

        }

        cout <<\"#Rolled \\t #Times \\t %Times\" << endl;

        cout <<\"----- \\t ------- \\t -------\" << endl;

        cout <<\" 1 \\t \" << num1 << \"\\t \" ;

        cout <<\" 2 \\t \" << num2 << \"\\t \";

        cout <<\" 3 \\t \" << num3 << \"\\t \"

        cout <<\" 4 \\t \" << num4 << \"\\t \" ;

        cout <<\" 5 \\t \" << num5 << \"\\t \" ;

        cout <<\" 6 \\t \" << num6 << \"\\t \" ;

system(\"PAUSE\");

        return 0;

}

 Create a C++ program that simulate rolling a die 100 times. The program displays the tally of the how many times for each number. For example: 16 times 20 time
 Create a C++ program that simulate rolling a die 100 times. The program displays the tally of the how many times for each number. For example: 16 times 20 time

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site