Question

Write a C++ program that uses a two dimensional array to display a table of probabilities...

Write a C++ program that uses a two dimensional array to display a table of probabilities for a pair of rolling dice. Your custom assigned range of values of each die are: 5 up to and including 10.

Section 1 of Program - Specifications:

The top row of the table, left to right, and the left column of the array, top to bottom, must contain the assigned range of values displayed on each of the die in ascending order populated through the use of a two dimensional array. The table must contain a total calculation formula resulting in a sum value when each of the values on the faces of each die are added together. (See sample output below.) Array population values cannot be hard coded into the array. Array population values must be derived from a calculation formula.

Section 2 of Program - Specifications:

After the table is populated with all of the probabilities, the program displays the possible total sum values and how many times that total sum value appears in the table. Program displays a label identifying this section of information on the output screen.

Section 3 of Program - Specifications:

Print out the array index values in brackets [ ] directly to the right of each total sum value in the table. Both the index values, in array index brackets as well as the total sum value must be printed.

Section 1 of the program must be completed in order to earn any points for section 3 of the program.

The completed program displays the program name and the student name at the top of the screen as well as section titles for sections 2 and 3. The output is formatted so that it is not displayed on the very first line and at the left margin of the run window. Finished table should be depicted as a table with the use of one character, repeated, so as to make the finished output table appear to be a grid.

The above is a generic sample of what the output will look to be used as a guide when writing code using your custom assigned range of values, located at the top of the specifications.

Section 1 of the program notes and restrictions – See page 1 for Section 1 specifications:

There should be a title line with the student name and there should be a title line with the name of the program, formatted so as not to be at the very top line of the run window and formatted so as not to be at the very left margin of the run window.

The program code must use a two dimensional array to populate the array. The table will have the custom range of values assigned to you in the top row and in the left column. The interior of the table will be created by using a total calculation formula to add each of the two values together, located on the face of each die. For example, in the generic sample above 1 in the top row added to 1 in the left column has a sum of 2; 2 in the top row and 1 in the left column has a sum of 3 etc. These values cannot be hard coded, or manually inserted by you. Instead each “sum” value is derived as the result of total formula calculation adding each of the row values to the left column values.

No points will be earned if any of the values in the table are “hard coded” or manually put into the code to have as output. All values must be derived by the use of code, arrays and calculated formulas, etc.

Section 2 of the program notes and restrictions– See page 1 for Section 2 specifications:

There should be a section title, clearly identifying what is being presented directly below this title. Section title should be formatted so as to have at least one blank line above it, separating this line of output from the last line of output directly above it. Section title should be also be formatted so as not to be directly at the left margin of the run window.

The program must use a counting variable to determine how many times each sum value appears in the grid. Then the number of times each sum value appears in the grid is output in the section below the grid. Only a sum value is to be counted. The values in the top label row and the values in the left label column are not counted. Only the number of times that a sum value appears in the table are to be counted and output in Section 2 output. No points will be earned unless the code determines how many times a sum value appears in the grid. If these values are “hard coded” or manually input into the code by you by viewing the output and manually writing the number of times a sum value appears in the code. There must be code used to count the number of appearances of each sum value in the grid.

Section 3 of the program notes and restrictions – See page 1 for Section 3 specifications:

There should be a section title, clearly identifying what is being presented directly below this title. Section title should be formatted so as to have at least one blank line above it, separating this line of output from the last line of output directly above it. Section title should be also be formatted so as not to be directly at the left margin of the run window.

The array index values should be printed to the right directly next to each sum value for the entire table. Each set of index values must be enclosed in its own set of brackets – [ ]. No points will be earned if each set of index values are not separated by a comma as well as are enclosed in their own set of brackets.


The incorporation of ANY concepts not covered in Chapters 1 through 3 is NOT ALLOWED!!! ANY concepts covered in Chapters 1 through 3 are allowed, with the exception of what is stated as being prohibited below

0 0
Add a comment Improve this question Transcribed image text
Answer #1

So according to the question the program that uses a two dimensional array to display a table of probabilities for a pair of rolling dice would be :

#include<iostream.h>

#include<conio.h>

#include<stdlib.h>

#include<time.h>

const int Limit = 6;

void main()

{

int n1, n2, res;

int arr[100];

cout << "\n ** Roll 2 Dices 100 times Each & Check the sums *** \n\n ";

cout << "\n ***** Output would ***** \n\n ";

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

{

cout << "\n YOUR TURN No. = " << n+1 << "\n";

// roll the first dice

cout << "\n Roll the first Dice ";

randomize();

n1 = random(Limit);

// roll the second dice

cout<< "\n Roll the sec dice :";

randomize();

n2 = random(Limit);

//sum of the drawn result

res = n1 + n2;

// store the sum in an array

arr[n] = res;

}

cout << "Now ,Try to Guess the sum of the result of the rolling two dices : "

//  Array for Guess No.

int g[100];

for( n=0 ; n< 100; n++)

{

cout<< "\n Predict The Sum For Turn : " << n+1;

cout << " Enter your number ( between 2 - 12) :";

cin >> g[n];

}

cout << " \n If the guess number and actual number matches You WON ";

cout<< "\n **** TABLE ****\n";

cout << "\n TURN \t SUM \t GuessNo. \t RESULT? \n";

// Print the result in tabular format

for( n=0 ; n< 100; n++)

{

// if guess no is equal to the sum , then WON , else LOST

if(g[n] == arr[n])

cout << "\n " << n+1 << "\t" << arr[n] << "\t" << g[n] << "\t" << "WON by guessing";

else

cout << "\n " << n+1 << "\t" << arr[n] << g[n] << "LOST by guessing";

// print 15 to 20 records at a time

if ( n == 15 || n == 35 || n == 55 || n == 75 )

{

cout << "\n Press any key to continue :";

getch();

clrscr();

}

}

getch();

}

" If you like the answer please give a like Thank You ! "

Add a comment
Know the answer?
Add Answer to:
Write a C++ program that uses a two dimensional array to display a table of probabilities...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create a program that uses a Jagged Array. The program will create an array with 50...

    Create a program that uses a Jagged Array. The program will create an array with 50 rows. Each of the values for each element of the array will be randomly generated. The random values will be between 1 and 20. Depending on the value generated for each row, you will create an array with that number of columns for that row. Each column created will contain the value to the left plus 1. After you create and populate the entire...

  • Part 2) write a C++ program that declares a 2 dimensional array: int CSIIAssign3 [10][12]; Initialize...

    Part 2) write a C++ program that declares a 2 dimensional array: int CSIIAssign3 [10][12]; Initialize your array using a text file, user input or assign value while declaring the array, you can choose the method. Then, a. Write a loop to print first row of the array on one line, using cout. b. Write a loop to print first column of the array on one line, using cout. c. Write a loop to print first five rows of the...

  • By using two-dimensional array, write Python program to display a table that represents a Pascal triangle...

    By using two-dimensional array, write Python program to display a table that represents a Pascal triangle of any size. In Pascal triangle, the first and the second rows are set to 5. Each element of the triangle (from the third row downward) is the sum of the element directly above it and the element to the left of the element directly above it. See the example Pascal triangle(size=6) below:                            5                            5       5                            5        10       ...

  • Three C Code Questions: 5. Write a C program that declares an array of 10 strings,...

    Three C Code Questions: 5. Write a C program that declares an array of 10 strings, each of max length 50 characters, and then reads an entire line of text from the keyboard into each string. 6. Write C code that finds the longest name in this array of strings that you read in Q5. Hint: find the position of the longest string, not the string itself. 7. Write a C program that creates a 4 x 6 two dimensional...

  • 7) Implement a two-dimensional grid with a one dimensional array. a) Implement an empty array of...

    7) Implement a two-dimensional grid with a one dimensional array. a) Implement an empty array of four integers. D) Request four integers from the console and store them into the array. In this array, the index represents a column, the value a row. c) Implement an output function to display the array as a two-dimensional grid of X's and dots where x is an array coordinate. Example output (input is bold and italicized) : Enter 4. row values (from 0...

  • IN JAVA Write a program that uses a two-dimensional array to store daily minutes walked and...

    IN JAVA Write a program that uses a two-dimensional array to store daily minutes walked and carb intake for a week. Prompt the user for 7 days of minutes walked and carb intake; store in the array.   Write a sort ( your choice which sort ) to report out the sorted minute values -lowest to highest. Write another to report out the sorted carb intake - highest to lowest. These methods MUST be your original code.   Your program should output...

  • C++ Lab 11 – Is This Box a Magic Box? Objectives: Define a two dimensional array Understand h...

    C++ Lab 11 – Is This Box a Magic Box? Objectives: Define a two dimensional array Understand how to traverse a two dimensional array Code and run a program that processes a two dimensional array Instructions: A magic square is a matrix (two dimensional arrays) in which the sum of each row, sum of each column, sum of the main diagonal, and sum of the reverse diagonal are all the same value. You are to code a program to determine...

  • In C++ for 2D Array: Write a program that uses a function that manipulates a 2D...

    In C++ for 2D Array: Write a program that uses a function that manipulates a 2D array of integers as follows: 1. Fill the first row and column in the array with random bits 2. Every subsequent cell should be filled as follows: 1. If the cells that are to the left and top of it are equal, then you should store their sum in it b. Otherwise, your program should store the highest among them. Test your function using...

  • Write a Java program to create a two-dimensional array, myFifthMatrix, with the following specifications:  Initialize...

    Write a Java program to create a two-dimensional array, myFifthMatrix, with the following specifications:  Initialize myFifthMatrix with int type and with size [3][3].  Use a for loop to fill the myFifthMatrix with random values between 0 and 99.  Print the myFifthMatrix using a for loop.  For each column, use a variable named total to store its sum. Add each element in the column to total using a for loop

  • C LANGUAGE!!! The program uses both files and two dimensional arrays. The Problem Statement Business is...

    C LANGUAGE!!! The program uses both files and two dimensional arrays. The Problem Statement Business is going well for your friend, who is selling discounts to area clubs and restaurants, which means that business is going well for you! Both of you have decided that you'll advertise on memory mall, which is roughly arranged as a rectangle. There's not enough time before a football game to hand flyers to everyone arranged on the mall. Therefore, you will only be able...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT