HomeWork #3 Program #1.cpp - #include #include...

Info icon This preview shows pages 1–2. Sign up to view the full content.

#include <iostream> #include <cmath> #include <cstdlib> #include <ctime> #include <iomanip> using namespace std; int main() { double times; int rolled; int num1 = 0; int num2 = 0; int num3 = 0; int num4 = 0; int num5 = 0; int num6 = 0; srand((unsigned int)time(0)); cout << "How many times would you like to roll the dice?"<<endl; cin >> times; while (times <= 0) { cout << "This is an invalid number. "<<endl; cout << "The number of rolls should be equal to or greater than 1." << endl; cout << "Please enter again."<<endl; cin >> times; } for (int i = 1; i <= times; 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 << "\nDICE ROLL STATISTICS"<<endl; cout << "\n# Rolled # Times % Times" << endl;
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

cout << "-------- -------- --------" << endl;
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.
  • Fall '14
  • Kristina Shroyer

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern