yes its in a loop here is what ive got.... i just need to figure out a way to where chips=100 isnt valid after the first time through the loop.
insert
Code:
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include"rollone.h"
int main(void){
double bet, chips, final;
int roll, roll1, status, point, i;
chips=100;
chips=final;
printf("* Welcome to my casino. The game this evening *\n");
printf("* is Craps. (Pass line bets only, but what do *\n");
printf("* you want from a class project?) *\n");
printf("* The minumum bet this evening is $2.00\n");
while(final>2) {
printf("You have $%.2f.\n", final);
printf("How much would you like to bet?");
scanf("%lf", &bet);
printf("\n");
if(bet>0 && bet<2) {
printf("I'm sorry, you can only bet between $2.00");
printf("and $%.2f (or 0 to quit).\n", final);
}
if(bet==0) {
printf("Your final bankroll is $%.2f.\n", final);
printf("Looks like you had a good night.\n");
printf("See the cashier on your way out.\n");
return 0;
}
srand(time(NULL));
roll= rollone(12);
printf("Coming out...%d\n", roll);
printf("Your point is %d\n", roll);
switch(roll) {
case 7:
case 11:
printf("A pass. We have a winner.\n");
printf("You win $%.2f\n", bet);
status=1;
break;
case 2:
case 3:
case 12:
printf("Craps.");
printf("You lose $%.2f.\n", bet);
status=2;
break;
default:
status=0;
point=roll;
break;
}
while(status==0) {
srand(time(NULL));
roll1=rollone(12);
printf("Coming out...%d\n", roll1);
printf("Your point is %d\n", roll1);
if(roll1==point) {
status=1;
}
else {
if(roll==7 || roll==11)
status=2;
}
}
if(status==1) {
printf("You win $%.2f\n", bet);
final=chips+bet;
}
if(status==2) {
final=chips-bet;
}
}
if(final==0) {
printf("I’m sorry. You can’t afford another bet.\n");
printf("Your final bankroll is $%.2f./n", final);
printf("Better luck next time.");
}
return 0;
}