Create a new file (in Dev C++) and save it as lab12_XYZ.cpp (replace XYZ with your initials). Create ANOTHER new file (in Dev C++) and save it as lab12_XYZ.h (replace XYZ with your initials). Use the H (header) file to declare constants and define functions. Make sure to #include "lab12_XYZ.h", and place H file in same location as your main program. Consider rolling two six-sided dice. While the result of each throw is independent of all rolls that have come before, we can still calculate the odds of rolling any given number between 2 and 12. This program will calculate those odds by generating a large number (100,000) of random values (i.e. "rolling the dice") and storing the results in an array. When all values have been rolled, we will display the results (counts and odds to 2 decimal places) to the user.   x   x   2   3   4   5   6   7   8   9   10  11  12     //value for sum of 2 dice rolls+---+---+---+---+---+---+---+---+---+---+---+---+---+|   |   |   |   |   |   |   |   |   |   |   |   |   |    //counters for number of times value is rolled+---+---+---+---+---+---+---+---+---+---+---+---+---+   0   1   2   3   4   5   6   7   8   9   10  11  12     //array index We need some constants int constants - NUM_ROLLS, NUM_SIDES, NUM_DICE, PRECISION, COLW1, COLW2, COLW3, etc. string constants - HELLO, GOODBYE, etc. We need some functions: void displayMessage(string);  //HELLO, GOODBYE, etc. (constants declared in your lab12_XYZ.h file...) int rollDice();  //returns a number between 2 and 12 (by rolling two dice and summing the result) void displayResults(int[]);  //displays results in the array In Lab 5, sample code was provided for generating a random number. Seed the random number generator in main(), then use rand() in the rollDice() function. #include <cstdlib>#include <ctime>unsigned seed = time(0);srand(seed);  //seed the RNGint num = (rand() % NUM_SIDES) + 1;   For this assignment: Header comments must be present in both CPP and H files Hello and goodbye messages must be shown Array(s) must be used for implementation DO NOT make arrays global variables Results should be formatted neatly (2 decimal places for odds, decimals lined up, etc.) Use comments and good style practices HINT: Make sure to initialize counter array before starting loop HINT: To calculate odds percentage: odds = count * 100 / NUM_ROLLS; SAMPLE OUTPUT:Welcome! This program will calculate the odds of rolling 2 - 12 with two 6-sided dice.Number of  2s rolled:         2776  ( 2.78%) Number of  3s rolled:         5518  ( 5.52%) Number of  4s rolled:         8234  ( 8.23%) Number of  5s rolled:        11273  (11.27%) Number of  6s rolled:        13884  (13.88%) Number of  7s rolled:        16594  (16.59%) Number of  8s rolled:        13848  (13.85%) Number of  9s rolled:        11102  (11.10%) Number of 10s rolled:         8394  ( 8.39%) Number of 11s rolled:         5580  ( 5.58%) Number of 12s rolled:         2797  ( 2.80%)Exiting program. Goodbye!   Lanauge is C++ Please make it as simple as possible.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Create a new file (in Dev C++) and save it as lab12_XYZ.cpp (replace XYZ with your initials).

Create ANOTHER new file (in Dev C++) and save it as lab12_XYZ.h (replace XYZ with your initials).

Use the H (header) file to declare constants and define functions. Make sure to #include "lab12_XYZ.h", and place H file in same location as your main program.

Consider rolling two six-sided dice. While the result of each throw is independent of all rolls that have come before, we can still calculate the odds of rolling any given number between 2 and 12. This program will calculate those odds by generating a large number (100,000) of random values (i.e. "rolling the dice") and storing the results in an array. When all values have been rolled, we will display the results (counts and odds to 2 decimal places) to the user.

  x   x   2   3   4   5   6   7   8   9   10  11  12     //value for sum of 2 dice rolls+---+---+---+---+---+---+---+---+---+---+---+---+---+|   |   |   |   |   |   |   |   |   |   |   |   |   |    //counters for number of times value is rolled+---+---+---+---+---+---+---+---+---+---+---+---+---+

  0   1   2   3   4   5   6   7   8   9   10  11  12     //array index

We need some constants

  • int constants - NUM_ROLLS, NUM_SIDES, NUM_DICE, PRECISION, COLW1, COLW2, COLW3, etc.
  • string constants - HELLO, GOODBYE, etc.

We need some functions:

  • void displayMessage(string);  //HELLO, GOODBYE, etc. (constants declared in your lab12_XYZ.h file...)
  • int rollDice();  //returns a number between 2 and 12 (by rolling two dice and summing the result)
  • void displayResults(int[]);  //displays results in the array

In Lab 5, sample code was provided for generating a random number. Seed the random number generator in main(), then use rand() in the rollDice() function.

#include <cstdlib>#include <ctime>unsigned seed = time(0);srand(seed);  //seed the RNGint num = (rand() % NUM_SIDES) + 1;

 

For this assignment:

  • Header comments must be present in both CPP and H files
  • Hello and goodbye messages must be shown
  • Array(s) must be used for implementation
  • DO NOT make arrays global variables
  • Results should be formatted neatly (2 decimal places for odds, decimals lined up, etc.)
  • Use comments and good style practices

HINT: Make sure to initialize counter array before starting loop

HINT: To calculate odds percentage: odds = count * 100 / NUM_ROLLS;

SAMPLE OUTPUT:Welcome! This program will calculate the odds of rolling 2 - 12 with two 6-sided dice.
Number of  2s rolled:         2776  ( 2.78%)

Number of  3s rolled:         5518  ( 5.52%)

Number of  4s rolled:         8234  ( 8.23%)

Number of  5s rolled:        11273  (11.27%)

Number of  6s rolled:        13884  (13.88%)

Number of  7s rolled:        16594  (16.59%)

Number of  8s rolled:        13848  (13.85%)

Number of  9s rolled:        11102  (11.10%)

Number of 10s rolled:         8394  ( 8.39%)

Number of 11s rolled:         5580  ( 5.58%)

Number of 12s rolled:         2797  ( 2.80%)
Exiting program. Goodbye!

 

Lanauge is C++

Please make it as simple as possible.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education