I cleaned up my code and ran it and one other problem is that I play 18 quarters at the end when I have 17 quarters left. See pic for reference
And GReaper slot machine 1 is only supposed to pay out 25 quarters after it is played 33 times so why would it pay out 25 quarters at the beginning of the program?
Here's Code updated
Code:
#include <stdio.h>
#include <windows.h>
int slot1(int, int );
int slot2(int, int );
double convertQuarters (int);
void main(){
int timesPlayed = 0;
int timesPlayed2 = 0;
int input3;
double x;
int quarters=1000;
while(quarters>0) {
//quarters--;
quarters+= slot1(timesPlayed++, --quarters );
quarters+= slot2(timesPlayed2++, --quarters );
quarters+= slot3(timesPlayed2++, --quarters );
Sleep(50);
} //End While Loop
system ("pause");
}
int slot1(int timesPlayed, int quarters)
{
int winnings=0;
printf ("Slot Machine One\n");
if (timesPlayed%33==0){
printf("You won on slot machine 1\n");
quarters+=25;
printf ("You have $%.2lf in quarters left\n", convertQuarters(quarters));
printf ("You have %d quarters left\n", quarters);
winnings= 25;
}
return winnings;
}
int slot2(int timesPlayed, int quarters)
{
int winnings=0;
printf ("Slot Machine Two\n");
if (timesPlayed%99==0){
printf("You won on slot machine 2\n");
quarters+=75;
printf ("You have $%.2lf in quarters left\n", convertQuarters(quarters));
printf ("You have %d quarters left\n", quarters);
winnings= 75;
}
return winnings;
}
int slot3(int timesPlayed, int quarters)
{
int winnings=0;
printf ("Slot Machine Three\n");
if (timesPlayed%9==0){
printf("You won on slot machine 3\n");
quarters+=7;
printf ("You have $%.2lf in quarters left\n", convertQuarters(quarters));
printf ("You have %d quarters left\n", quarters);
winnings= 7;
}
return winnings;
}
double convertQuarters (int quarters)
{
double result;
result=quarters*.25;
return result;
}