Question: C++, So I have to do the following assignment. I wrote some code, however there are somethings wrong with it, and I can't figured it
C++, So I have to do the following assignment. I wrote some code, however there are somethings wrong with it, and I can't figured it out. Below I'll posted the instructions of the assignment and then some of the code that I wrote for it. I couldn't post all of the code because it was too large.
Description
For this assignment, you will write a C++ program to simulate the Deal or No Deal game show. Your program should follow the rules of the game show. After each case is opened, your program should display both the dollar amounts that are still in play and also the cases that remain unopened. After all the cases in a particular round have been opened, your program should display an offer for the user and ask for a deal or no deal response. If the user takes the deal then the game terminates immediately otherwise the game continues on to the next round. The number of cases to be opened in each round is based on the following chart
Round 1---- cases to open(6). Round 2---- cases to open(5). Round 3---- cases to open(4). Round 4---- cases to open(3). Round 5---------cases to open( 2). Round 6-9------ cases to open(1)
If the user does not take the deal at the end of round nine, then she gets the option of either keeping her original case or switching it with the last remaining case. The users decision in this last round determines how much money she wins. Your program should print out a message showing the amount of money won by the user after the last round of play.
Implementation Instructions
- You should use a struct to represent each case and an array of structs to hold information about all 26 cases.
- You should use a random number generator to randomly assign dollar amounts to each case at the start of the game. Note, when generating numbers, you need to make sure that the same random value is not assigned to multiple cases.
- You have some flexibility in terms of what formula to use to generate the bank offers. A simple heuristic would be to use the average worth of the unopened cases.
- You should define several functions for this program. For example, the display of dollar amounts and cases, initialization of cases and the formula for computing the bank offer, should all go into separate functions.
- You should do some amount of error checking. In particular, if the user attempts to open a case outside the range of 1-26, your program should print an error message and ask for input again.
- You should not have any global variables in this program.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Here's the code that I wrote for this assignment.
NOTE: My shuffling of the array using a random number generator to randomly assign dollar amounts to each case at the start of the game repeats the numbers and is not supposed to do that, but I don't know how to fix this. I couldn't posted all of my code but I just want help with this, and I can't use vectors for these problem.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#include
struct cases{
int caseNumber; double moneyValueIncase; bool isOpen = false ; };
double shuffle() { double money_values[26] = {.01,1,5,10,25,50,75,100,200,300,400,500,750,1000,5000,10000,25000,50000,75000,100000,200000,300000,400000,500000,750000,1000000}; int randomIndex = 0; // my index inside my cases array randomIndex = (rand()% 26); return money_values[randomIndex];
}
int main() {
srand(time(NULL)); cases box[26]; for (int i=0; i<26; i++) { box[i].caseNumber = i+1; box[i].moneyValueIncase = shuffle(); box[i].isOpen; }
//I am cout all of the cases numbers with there money values to see if they are being randomize and not repeating the money value. This the part I need help with I can't use vectors. and I need to make with the numbers inside the array cout << box[0].moneyValueIncase<< " "<<"Case: "< cout<<"Welcome to Deal or no deal. Please choose a case"<
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
