I'm having issues with this checkbook program. The probelm is when I deposit money into the balance it still shows me the old overdrafted balance. I am thinking that it has to do with my:
bal += CreditDebit;
Here is my code so far:
#include <stdio.h>
#include <stdlib.h>
int main ()
{
float bal, CreditDebit;
printf("This is your checkbook balancing utility.\n");
printf("You will enter your current balance followed by\n");
printf("checkbook entries. Use + and - to indicate deposits\n");
printf("and withdrawals. Signal the end of processing by\n");
printf("entering a '0'\n");
printf(">>>Please enter your initial balance: ");
scanf("%f", &bal);
while (CreditDebit != 0) {
printf("\n");
printf("Enter deposit (+) or Withdrawl (-): ");
scanf("%f", &CreditDebit);
bal += CreditDebit;
if (bal < 0) {
printf("***I am sorry, you have bounced this check. $10 will be deducted\n");
bal -= 10;
}
printf("Current balance: %.2f\n", bal);
}
printf("\nAt end of program your final balance is: %.2f\n",bal);
system("pause");
exit(0);
}
Any help would be appreciated.