Little bug killer:
Replace the old top few lines in main with this:
Code:
int main(){
long int a[MAXCASE]={0,1,2,5,10,25,50,75,100,200,300,400,500,750,1000,5000,
10000,25000,50000,75000,100000,200000,300000,400000,500000,750000,1000000};
long int bankerOffer,sum,divideBy;
int isOpen[27];
int remainingCase,choice,mainBriefcase,toChoose;
char chchoice;
int i,j,deal,roundNum,temp,youWon;
sum is now a long int, and there's a new variable "divideBy", that is also a long.
There is a bug in the bankerOffer calculation. This is the fix for it:
Code:
printf("Now we'll see what the banker will offer. Here's the phone call now\a\a\a\n");
sum=0;
divideBy=0;
for(i=1;i<MAXCASE;i++) {
if(isOpen[i]==0) {
sum+=a[i];
divideBy++;
}
}
bankerOffer = sum/divideBy;
and in the amount that you win when you make a deal, replace these lines, to fix a bug there:
Code:
printf("Now the question to you is: Deal, or No Deal [y/n]: ");
scanf(" %c",&chchoice);
getchar();
if(chchoice=='y' || chchoice=='Y') {
deal=1;
youWon=bankerOffer;
}
}
printf("Thanks for playing Deal or No Deal ");
if(deal==1) {
printf("You won %ld", bankerOffer);
}
else {
printf("You won : %ld", a[mainBriefcase]);
Most of the above lines are correct, but included so you can find where the correct lines of code go, inside the program.
Should be a simple copy and paste.
I thought for the display of the dollar amounts still remaining WITHOUT having their briefcases numbered, it could be done like this:
in showCases(), make a long int a2[MAXCASE], array. Then in a for loop from 1 to MAXCASE-1, copy the a[] array over to the a2 array.
Then sort the a2 array, (not the a[] array!), and display the a2 array, without the briefcase numbers, in sorted order.
Then below that, use a similar for loop to go through the isOpen[] array. Any isOpen[i] that == 0, should print that i number. That is a briefcase that still can be chosen, so print them out:
1 2 4 5 6 8 ... etc.
and it looks very much like the board on the game. Regrettably, no pretty girls holding the cases.