#include <iostream> #include <string> #include <cmath> #include <cctype> #includ
ID: 3598508 • Letter: #
Question
#include <iostream>
#include <string>
#include <cmath>
#include <cctype>
#include <iomanip>
#include <ctime>
using namespace std;
int main() {
const int optionOneChip = 1;
const int optionMultChip = 2;
const int optionShowOptions = 3;
const int optionQuit = 4;
int menuChoice = 0;
double chipLocation = 0.0;
const int SEED_VAL = 42;
const int NUM_ROWS = 12;
const int CHIP_CHANCE = 2;
int r = 0;
double randomNum;
double prizeOne = 100.00;
double prizeTwo = 500.00;
double prizeThree = 1000.00;
double prizeFour = 0.00;
double prizeFive = 10000.00;
int initialChipLocation;
int numChips = 0;
int n = 0;
double totalMoney = 0.00;
double averageMoney = 0.00;
srand(SEED_VAL);
cout << "Welcome to the Plinko simulator! Enter " << optionShowOptions << " to see options." << endl;
cout << endl;
do {
cout << "Enter your selection now: " << endl;
cout << endl;
cin >> menuChoice;
if (menuChoice == optionQuit) {
cout << "Goodbye!";
}
else if (menuChoice == optionShowOptions) {
cout << "Menu: Please select one of the following options:" << endl;
cout << endl;
cout << optionOneChip << " - " << "Drop a single chip into one slot" << endl;
cout << optionMultChip << " - " << "Drop multiple chips into one slot" << endl;
cout << optionShowOptions << " - " << "Show the options menu" << endl;
cout << optionQuit << " - " << "Quit the program" << endl;
}
else if (menuChoice == optionOneChip) {
cout << "*** Drop a single chip ***" << endl;
cout << endl;
cout << "Which slot do you want to drop the chip in (0-8)?" << endl;
cin >> initialChipLocation;
if (initialChipLocation >= 0 && initialChipLocation <= 8) {
cout << "*** Dropping chip into slot " << initialChipLocation << " ***" << endl;
chipLocation = initialChipLocation;
cout << fixed << setprecision(1);
cout << "Path: [" << chipLocation;
for (r = 1; r <= NUM_ROWS; r++) {
if (r <= NUM_ROWS) {
cout << ", ";
}
if(chipLocation == 0.0){
chipLocation = chipLocation + 0.5;
cout << chipLocation;
continue;
}
else if(chipLocation == 8.0){
chipLocation = chipLocation - 0.5;
cout << chipLocation;
continue;
}
randomNum = rand() % CHIP_CHANCE;
if(randomNum == 0) {
chipLocation = chipLocation - 0.5;
cout << chipLocation;
}
else if(randomNum == 1){
chipLocation = chipLocation + 0.5;
cout << chipLocation;
}
}
cout << "]";
cout << endl;
cout << fixed << setprecision(2);
if (chipLocation == 0.0 || chipLocation == 8.0) {
cout << "Winnings: $" << prizeOne;
}
if (chipLocation == 1.0 || chipLocation == 7.0) {
cout << "Winnings: $" << prizeTwo;
}
if (chipLocation == 2.0 || chipLocation == 6.0) {
cout << "Winnings: $" << prizeThree;
}
if (chipLocation == 3.0 || chipLocation == 5.0) {
cout << "Winnings: $" << prizeFour;
}
if (chipLocation == 4.0) {
cout << "Winnings: $" << prizeFive;
}
cout << endl;
cout << endl;
}
else {
cout << "Invalid slot." << endl;
cout << endl;
}
}
else if (menuChoice == optionMultChip) {
cout << "*** Drop multiple chips ***" << endl;
cout << endl;
cout << "How many chips do you want to drop (>0)?" << endl;;
cin >> numChips;
if (numChips > 0) {
cout << "Which slot do you want to drop the chip in (0-8)?" << endl;
cin >> initialChipLocation;
if (initialChipLocation >= 0 && initialChipLocation <= 8) {
cout << fixed << setprecision(1);
for (n = 1; n <= numChips; n++) {
chipLocation = initialChipLocation;
for (r = 1; r <= NUM_ROWS; r++) {
if(chipLocation == 0.0) {
chipLocation = chipLocation + 0.5;
continue;
}
else if(chipLocation == 8.0) {
chipLocation = chipLocation - 0.5;
continue;
}
randomNum = rand() % CHIP_CHANCE;
if(randomNum == 0) {
chipLocation = chipLocation - 0.5;
}
else if(randomNum == 1) {
chipLocation = chipLocation + 0.5;
}
}
if (chipLocation == 0.0 || chipLocation == 8.0) {
totalMoney = totalMoney + prizeOne;
}
if (chipLocation == 1.0 || chipLocation == 7.0) {
totalMoney = totalMoney + prizeTwo;
}
if (chipLocation == 2.0 || chipLocation == 6.0) {
totalMoney = totalMoney + prizeThree;
}
if (chipLocation == 3.0 || chipLocation == 5.0) {
totalMoney = totalMoney + prizeFour;
}
if (chipLocation == 4.0) {
totalMoney = totalMoney + prizeFive;
}
}
cout << fixed << setprecision(2);
cout << "Total winnings on " << numChips << " chips: $" << totalMoney << endl;
averageMoney = totalMoney / numChips;
cout << "Average winnings per chip: $" << averageMoney << endl << endl;
averageMoney = 0.00;
totalMoney = 0.00;
}else {
cout << "Invalid slot.";
cout << endl;
cout << endl;
}
}
else {
cout << "Invalid number of chips.";
cout << endl;
cout << endl;
}
}
else if (menuChoice == optionQuit) {
cout << "Goodbye!";
}
else {
cout << "Invalid selection. Enter " << optionShowOptions << " to see options." << endl;
}
} while (menuChoice != optionQuit);
//system("pause");
return 0;
}
Part 1 - Refactoring (35 points)
"Refactor" your Lab 4 code (i.e. preferably do not rewrite Lab 4 from scratch) using functions. Wikipedia explains that "Code refactoring is the process of restructuring existing computer code... Advantages include improved code readability and reduced complexity... Typically, refactoring applies a series of standardised basic micro-refactorings, each of which is (usually) a tiny change in a computer program's source code that ... preserves the behaviour of the software". In the end we really cannot tell if you refactored your lab 4 code or just re-wrote it from scratch, but we encourage you to start with your code for lab 4 and move the code around to achieve a simpler, better program. Before refactoring, you are strongly encouraged to COPY your Lab 4 code into a new solution for Lab 6 (rather than to edit your Lab 4 code directly). This way, if your Lab 6 code gets too scrambled, you still have your Lab 4 code from which to start over. In particular we are expecting to see functions for:
Computing the amount of prize money won for a single chip given the slot the chip ended up in-- this function must be defined as "double ComputeWinnings(int slot) {... your code here ...}. (See the original Plinko lab for the complete list of these values). If you have not declared and named this function exactly as specified you will no pass the initial unit tests in auto-grade which just test this function. Also, this time we want you to represent the winnings as a constant so that it would be easy to create a new Plinko board by just changing the constant. Hint: Think of using a constant array of values to represent the winnings for each slot.
Simulating one chip falling-- you will have to use your discretion on how you name and code this, but it should make both the "Drop a single chip into one slot" option and the next function (Simulating multiple chips falling) easier to write. This function must make use of the "ComputeWinnings" function described above.
Simulating multiple chips falling-- similarly this function should make both the "Drop multiple chips into one slot" option and a new "Drop multiple chips into each slot" option (described below) easier to write. This function must make use of the "Simulating one chip falling" function described above.
Your Lab 6 solution must include all the features of Lab 4.
Add a new menu item for "Drop multiple chips into each slot", but you do not have to implement it yet. You will implement it in Part 3.
We will update the error handling in Part 2, so for Part 1, you may assume that there will be no input errors.
Part 2 - Better Error Handling (30 points)
Add a function for getting the number of chips and a function for getting the slot number. Within these functions check for user input error and reprompt until the user provides valid input. You must be able to recognize erroneous input like "-1", "x", "Not even a number", and in the case of a slot number, invalid integers like "9". You may assume that there will be no real-valued inputs like "2.3". Add a function for getting the menu option also, reprompting if an erroneous option is input.
If you think about it for a minute you will realize that you could use a single function rather than three separate functions for inputting a correct integer. Obviously it would need additional parameters to work as required in each case, but it is a better approach. We encourage you to do it with just one function. More general functions like this have the advantage of being re-usable in later programs which need an integer input, rather than having to write a new function for each specific variation on inputting an integer.
Part 3 - Functions and the Power of Code Reuse (20 points)
In this part of the lab, you will take advantage of functions to add an additional menu option to your Plinko program, without having to duplicate code from the other menu options.
Add a new menu option 3 that allows the user to drop the same number of chips into each of the 9 slots. For example, if the user enters 5, you simulate dropping 5 chips into each of the 9 slots.
Prompt the user to enter one number, which is the number of chips to drop into every slot. If the number of chips is non-positive or a string, etc., reprompt until you get valid input (hint: just use the function you wrote in Part 2)
For each slot, report the total and average amount of money won for all chips dropped into that slot.
Hint: You should be able to write this new option easily by just using functions you have already created. No new functions should be necessary. Also, try this option with a large number of chips (try a million) and you will see which slots really are best on average. See if you can notice a type of "Bell curve."
This has to be done with functions. This program I have currently is just a bunch of for loops--it works perfectly, but I need to use functions now. I need help with this. Thanks.
Explanation / Answer
Answer:
Note: User given code is modified.
Part 1:
Implementing function ComputeWinnings():
Code:
#include <iostream>
#include <string>
#include <cmath>
#include <cctype>
#include <iomanip>
#include <ctime>
using namespace std;
const int NUM_ROWS = 12;
const int CHIP_CHANCE = 2;
double ComputeWinnings(int slot)
{
double chipLocation = 0.0;
double randomNum;
double prizeValues[9]={100.00,500.00,1000.00,0.00,10000.00,0.00,1000.00,500.00,100.00};
for (int r = 1; r <= NUM_ROWS; r++)
{
if(chipLocation == 0.0){
chipLocation = chipLocation + 0.5;
continue;
}
else if(chipLocation == 8.0){
chipLocation = chipLocation - 0.5;
continue;
}
randomNum = rand() % CHIP_CHANCE;
if(randomNum == 0) {
chipLocation = chipLocation - 0.5;
}
else if(randomNum == 1){
chipLocation = chipLocation + 0.5;
}
}
return prizeValues[slot];
}
int main() {
const int optionOneChip = 1;
const int optionMultChip = 2;
const int optionShowOptions = 3;
const int optionQuit = 4;
int menuChoice = 0;
double chipLocation = 0.0;
const int SEED_VAL = 42;
//const int NUM_ROWS = 12;
int r = 0;
int initialChipLocation;
int numChips = 0;
int n = 0;
double totalMoney = 0.00;
double averageMoney = 0.00;
srand(SEED_VAL);
cout << "Welcome to the Plinko simulator! Enter " << optionShowOptions << " to see options." << endl;
cout << endl;
do {
cout << "Enter your selection now: " << endl;
cout << endl;
cin >> menuChoice;
if (menuChoice == optionQuit) {
cout << "Goodbye!";
}
else if (menuChoice == optionShowOptions) {
cout << "Menu: Please select one of the following options:" << endl;
cout << endl;
cout << optionOneChip << " - " << "Drop a single chip into one slot" << endl;
cout << optionMultChip << " - " << "Drop multiple chips into one slot" << endl;
cout << optionShowOptions << " - " << "Show the options menu" << endl;
cout << optionQuit << " - " << "Quit the program" << endl;
}
else if (menuChoice == optionOneChip) {
cout << "*** Drop a single chip ***" << endl;
cout << endl;
cout << "Which slot do you want to drop the chip in (0-8)?" << endl;
cin >> initialChipLocation;
if (initialChipLocation >= 0 && initialChipLocation <= 8) {
cout << "*** Dropping chip into slot " << initialChipLocation << " ***" << endl;
chipLocation = initialChipLocation;
cout << fixed << setprecision(2);
cout << "Winnings: $" << ComputeWinnings(initialChipLocation);
cout << endl;
cout << endl;
}
else {
cout << "Invalid slot." << endl;
cout << endl;
}
}
else if (menuChoice == optionMultChip) {
cout << "*** Drop multiple chips ***" << endl;
cout << endl;
cout << "How many chips do you want to drop (>0)?" << endl;;
cin >> numChips;
if (numChips > 0) {
cout << "Which slot do you want to drop the chip in (0-8)?" << endl;
cin >> initialChipLocation;
if (initialChipLocation >= 0 && initialChipLocation <= 8)
{
cout << fixed << setprecision(1);
for (n = 1; n <= numChips; n++)
{
totalMoney = totalMoney + ComputeWinnings(initialChipLocation);
}
cout << fixed << setprecision(2);
cout << "Total winnings on " << numChips << " chips: $" << totalMoney << endl;
averageMoney = totalMoney / numChips;
cout << "Average winnings per chip: $" << averageMoney << endl << endl;
averageMoney = 0.00;
totalMoney = 0.00;
}
else
{
cout << "Invalid slot.";
cout << endl;
cout << endl;
}
}
else
{
cout << "Invalid number of chips.";
cout << endl;
cout << endl;
}
}
else if (menuChoice == optionQuit)
{
cout << "Goodbye!";
}
else
{
cout << "Invalid selection. Enter " << optionShowOptions << " to see options." << endl;
}
} while (menuChoice != optionQuit);
//system("pause");
return 0;
}
Sample Output:
Welcome to the Plinko simulator! Enter 3 to see options.
Enter your selection now:
3
Menu: Please select one of the following options:
1 - Drop a single chip into one slot
2 - Drop multiple chips into one slot
3 - Show the options menu
4 - Quit the program
Enter your selection now:
1
*** Drop a single chip ***
Which slot do you want to drop the chip in (0-8)?
5
*** Dropping chip into slot 5 ***
Winnings: $0.00
Enter your selection now:
2
*** Drop multiple chips ***
How many chips do you want to drop (>0)?
20
Which slot do you want to drop the chip in (0-8)?
4
Total winnings on 20 chips: $200000.00
Average winnings per chip: $10000.00
Enter your selection now:
4
Goodbye!
Part 2:
Implementing function to get input:
Code:
#include <iostream>
#include <string>
#include <cmath>
#include <cctype>
#include <iomanip>
#include <ctime>
using namespace std;
const int NUM_ROWS = 12;
const int CHIP_CHANCE = 2;
//Part 1
double ComputeWinnings(int slot)
{
double chipLocation = 0.0;
double randomNum;
double prizeValues[9]={100.00,500.00,1000.00,0.00,10000.00,0.00,1000.00,500.00,100.00};
for (int r = 1; r <= NUM_ROWS; r++)
{
if(chipLocation == 0.0){
chipLocation = chipLocation + 0.5;
continue;
}
else if(chipLocation == 8.0){
chipLocation = chipLocation - 0.5;
continue;
}
randomNum = rand() % CHIP_CHANCE;
if(randomNum == 0) {
chipLocation = chipLocation - 0.5;
}
else if(randomNum == 1){
chipLocation = chipLocation + 0.5;
}
}
return prizeValues[slot];
}
//Part 2
int GetChoice(char *message, int lowr, int uppr)
{
int retVal=1;
while(1)
{
cout<<message<<endl;
cin>>retVal;
if(retVal<lowr || retVal>uppr)
{
cout<<"Invalid option. Please try again."<<endl;
continue;
}
break;
}
return retVal;
}
int main() {
const int optionOneChip = 1;
const int optionMultChip = 2;
const int optionShowOptions = 3;
const int optionQuit = 4;
int menuChoice = 0;
double chipLocation = 0.0;
const int SEED_VAL = 42;
//const int NUM_ROWS = 12;
int r = 0;
int initialChipLocation;
int numChips = 0;
int n = 0;
double totalMoney = 0.00;
double averageMoney = 0.00;
srand(SEED_VAL);
cout << "Welcome to the Plinko simulator! Enter " << optionShowOptions << " to see options." << endl;
cout << endl;
do {
menuChoice=GetChoice( "Enter your selection now: ",1,4) ;
if (menuChoice == optionQuit) {
cout << "Goodbye!";
}
else if (menuChoice == optionShowOptions) {
cout << "Menu: Please select one of the following options:" << endl;
cout << endl;
cout << optionOneChip << " - " << "Drop a single chip into one slot" << endl;
cout << optionMultChip << " - " << "Drop multiple chips into one slot" << endl;
cout << optionShowOptions << " - " << "Show the options menu" << endl;
cout << optionQuit << " - " << "Quit the program" << endl;
}
else if (menuChoice == optionOneChip) {
cout << "*** Drop a single chip ***" << endl;
cout << endl;
initialChipLocation=GetChoice("Which slot do you want to drop the chip in (0-8)?",0,8);
if (initialChipLocation >= 0 && initialChipLocation <= 8) {
cout << "*** Dropping chip into slot " << initialChipLocation << " ***" << endl;
chipLocation = initialChipLocation;
cout << fixed << setprecision(2);
cout << "Winnings: $" << ComputeWinnings(initialChipLocation);
cout << endl;
cout << endl;
}
else {
cout << "Invalid slot." << endl;
cout << endl;
}
}
else if (menuChoice == optionMultChip) {
cout << "*** Drop multiple chips ***" << endl;
cout << endl;
numChips = GetChoice("How many chips do you want to drop (>0)?",1,10000);
if (numChips > 0) {
initialChipLocation=GetChoice("Which slot do you want to drop the chip in (0-8)?",0,8);
if (initialChipLocation >= 0 && initialChipLocation <= 8)
{
cout << fixed << setprecision(1);
for (n = 1; n <= numChips; n++)
{
totalMoney = totalMoney + ComputeWinnings(initialChipLocation);
}
cout << fixed << setprecision(2);
cout << "Total winnings on " << numChips << " chips: $" << totalMoney << endl;
averageMoney = totalMoney / numChips;
cout << "Average winnings per chip: $" << averageMoney << endl << endl;
averageMoney = 0.00;
totalMoney = 0.00;
}
else
{
cout << "Invalid slot.";
cout << endl;
cout << endl;
}
}
else
{
cout << "Invalid number of chips.";
cout << endl;
cout << endl;
}
}
else if (menuChoice == optionQuit)
{
cout << "Goodbye!";
}
else
{
cout << "Invalid selection. Enter " << optionShowOptions << " to see options." << endl;
}
} while (menuChoice != optionQuit);
//system("pause");
return 0;
}
Sample Output:
Welcome to the Plinko simulator! Enter 3 to see options.
Enter your selection now:
3
Menu: Please select one of the following options:
1 - Drop a single chip into one slot
2 - Drop multiple chips into one slot
3 - Show the options menu
4 - Quit the program
Enter your selection now:
5
Invalid option. Please try again.
Enter your selection now:
1
*** Drop a single chip ***
Which slot do you want to drop the chip in (0-8)?
9
Invalid option. Please try again.
Which slot do you want to drop the chip in (0-8)?
4
*** Dropping chip into slot 4 ***
Winnings: $10000.00
Enter your selection now:
3
Menu: Please select one of the following options:
1 - Drop a single chip into one slot
2 - Drop multiple chips into one slot
3 - Show the options menu
4 - Quit the program
Enter your selection now:
2
*** Drop multiple chips ***
How many chips do you want to drop (>0)?
-1
Invalid option. Please try again.
How many chips do you want to drop (>0)?
5
Which slot do you want to drop the chip in (0-8)?
6
Total winnings on 5 chips: $5000.00
Average winnings per chip: $1000.00
Enter your selection now:
4
Goodbye!
Part 3:
Dropping chips into each slot:
Code:
#include <iostream>
#include <string>
#include <cmath>
#include <cctype>
#include <iomanip>
#include <ctime>
using namespace std;
const int NUM_ROWS = 12;
const int CHIP_CHANCE = 2;
//Part 1
double ComputeWinnings(int slot)
{
double chipLocation = 0.0;
double randomNum;
double prizeValues[9]={100.00,500.00,1000.00,0.00,10000.00,0.00,1000.00,500.00,100.00};
for (int r = 1; r <= NUM_ROWS; r++)
{
if(chipLocation == 0.0){
chipLocation = chipLocation + 0.5;
continue;
}
else if(chipLocation == 8.0){
chipLocation = chipLocation - 0.5;
continue;
}
randomNum = rand() % CHIP_CHANCE;
if(randomNum == 0) {
chipLocation = chipLocation - 0.5;
}
else if(randomNum == 1){
chipLocation = chipLocation + 0.5;
}
}
return prizeValues[slot];
}
//Part 2
int GetChoice(char *message, int lowr, int uppr)
{
int retVal=1;
while(1)
{
cout<<message<<endl;
cin>>retVal;
if(retVal<lowr || retVal>uppr)
{
cout<<"Invalid option. Please try again."<<endl;
continue;
}
break;
}
return retVal;
}
int main() {
const int optionOneChip = 1;
const int optionMultChip = 2;
const int optionMultSlot = 3;
const int optionQuit = 4;
int menuChoice = 0;
double chipLocation = 0.0;
const int SEED_VAL = 42;
int r = 0;
int initialChipLocation;
int numChips = 0;
int n = 0;
double totalMoney = 0.00;
double averageMoney = 0.00;
srand(SEED_VAL);
cout << "Welcome to the Plinko simulator! ." << endl;
cout << endl;
do
{
cout << "Menu: Please select one of the following options:" << endl;
cout << endl;
cout << optionOneChip << " - " << "Drop a single chip into one slot" << endl;
cout << optionMultChip << " - " << "Drop multiple chips into one slot" << endl;
cout << optionMultSlot << " - " << "Drop multiple chips into multiple slots" << endl;
cout << optionQuit << " - " << "Quit the program" << endl;
menuChoice=GetChoice( "Enter your selection now: ",1,4) ;
if (menuChoice == optionOneChip)
{
cout << "*** Drop a single chip ***" << endl;
cout << endl;
initialChipLocation=GetChoice("Which slot do you want to drop the chip in (0-8)?",0,8);
cout << "*** Dropping chip into slot " << initialChipLocation << " ***" << endl;
chipLocation = initialChipLocation;
cout << fixed << setprecision(2);
cout << "Winnings: $" << ComputeWinnings(initialChipLocation);
cout << endl;
cout << endl;
}
else if (menuChoice == optionMultChip)
{
cout << "*** Drop multiple chips ***" << endl;
cout << endl;
numChips = GetChoice("How many chips do you want to drop (>0)?",1,10000);
initialChipLocation=GetChoice("Which slot do you want to drop the chip in (0-8)?",0,8);
cout << fixed << setprecision(1);
for (n = 1; n <= numChips; n++)
{
totalMoney = totalMoney + ComputeWinnings(initialChipLocation);
}
cout << fixed << setprecision(2);
cout << "Total winnings on " << numChips << " chips: $" << totalMoney << endl;
averageMoney = totalMoney / numChips;
cout << "Average winnings per chip: $" << averageMoney << endl << endl;
averageMoney = 0.00;
totalMoney = 0.00;
}
//Part 3
else if (menuChoice == optionMultSlot)
{
cout << "*** Drop multiple chips into multiple slots***" << endl;
cout << endl;
numChips = GetChoice("How many chips do you want to drop (>0)?",1,10000);
for(int kk=0;kk<9;kk++)
{
initialChipLocation=kk;
cout << fixed << setprecision(1);
for (n = 1; n <= numChips; n++)
{
totalMoney = totalMoney + ComputeWinnings(initialChipLocation);
}
cout << fixed << setprecision(2);
cout << "Total winnings on " << numChips << " chips: $" << totalMoney << endl;
averageMoney = totalMoney / numChips;
cout << "Average winnings per chip: $" << averageMoney << endl << endl;
averageMoney = 0.00;
totalMoney = 0.00;
}
}
else if (menuChoice == optionQuit)
{
cout << "Goodbye!";
}
else
{
cout << "Invalid selection. ." << endl;
}
} while (menuChoice != optionQuit);
//system("pause");
return 0;
}
Sample output:
Welcome to the Plinko simulator! .
Menu: Please select one of the following options:
1 - Drop a single chip into one slot
2 - Drop multiple chips into one slot
3 - Drop multiple chips into multiple slots
4 - Quit the program
Enter your selection now:
1
*** Drop a single chip ***
Which slot do you want to drop the chip in (0-8)?
4
*** Dropping chip into slot 4 ***
Winnings: $10000.00
Menu: Please select one of the following options:
1 - Drop a single chip into one slot
2 - Drop multiple chips into one slot
3 - Drop multiple chips into multiple slots
4 - Quit the program
Enter your selection now:
2
*** Drop multiple chips ***
How many chips do you want to drop (>0)?
6
Which slot do you want to drop the chip in (0-8)?
3
Total winnings on 6 chips: $0.00
Average winnings per chip: $0.00
Menu: Please select one of the following options:
1 - Drop a single chip into one slot
2 - Drop multiple chips into one slot
3 - Drop multiple chips into multiple slots
4 - Quit the program
Enter your selection now:
3
*** Drop multiple chips into multiple slots***
How many chips do you want to drop (>0)?
80
Total winnings on 80 chips: $8000.00
Average winnings per chip: $100.00
Total winnings on 80 chips: $40000.00
Average winnings per chip: $500.00
Total winnings on 80 chips: $80000.00
Average winnings per chip: $1000.00
Total winnings on 80 chips: $0.00
Average winnings per chip: $0.00
Total winnings on 80 chips: $800000.00
Average winnings per chip: $10000.00
Total winnings on 80 chips: $0.00
Average winnings per chip: $0.00
Total winnings on 80 chips: $80000.00
Average winnings per chip: $1000.00
Total winnings on 80 chips: $40000.00
Average winnings per chip: $500.00
Total winnings on 80 chips: $8000.00
Average winnings per chip: $100.00
Menu: Please select one of the following options:
1 - Drop a single chip into one slot
2 - Drop multiple chips into one slot
3 - Drop multiple chips into multiple slots
4 - Quit the program
Enter your selection now:
4
Goodbye!
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.