Martha takes a jar of quarters to the casino with the intention of becoming rich. She plays three machines in turn. Unknown to her, the machines are entirely predictable. Each play costs one quarter. The first machine pays 30 quarters every 35th time it is played; the second machine pays 60 quarters every 100th time it is played; the third pays 9 quarters every 10th time it is played.
Your program should take as input the number of quarters in Martha's jar (there will be at least one and fewer than 1000), and the number of times each machine has been played since it last paid.
Your program should output the number of times Martha plays until she goes broke.
Use the following test cases:
Use the following cases to test your slot machine program:
# plays since last payout Total # of plays
# of coins in
the jar
Machine #1 Machine #2 Machine #3 Result from your program
50 5 50 5 68
999 10 10 0 4374
123 3 2 1 255
I just can't seem to get it to output the right numbers!!! The program runs but as I said I've messed up in the calculations so I just don't know.
#include <iostream>
#include <cstdlib>
usingnamespace std;
int main(int argc, char* argv[])
{
int jar;
int playscount=0;
int turn1;
int turn2;
int turn3;
cout<< "How many quarters are in the jar?" <<endl;
cin>> jar;
cout<< "How many times has the first machine been played since it's last payout?" <<endl;
cin>> turn1;
cout<< "How many times has the second machine been played since it's last payout?" <<endl;
cin>> turn2;
cout<< "How many times has the second machine been played since it's last payout?" <<endl;
cin>> turn3;
while (jar > 0)
{
turn1 ++;
playscount++;
if (turn1==35)
{
jar+=30;
}
turn2 ++;
playscount ++;
if (turn2==10)
{
jar+=9;
}
if (turn3==100)
{
jar+=60;
}
}
cout<< "Martha plays" << playscount << "times before going broke.";
system("PAUSE");
return EXIT_SUCCESS;
}