In my code, I cannot figure why it still is calculating wrong:
here is the execute:
BANK RECONCILIATION FOR: 10/21/98
Ending balance on statement:350
Enter Outstanding dep (or 0 to quit)>75
Enter outstanding dep (0 to quit)>20
Enter outstanding dep (0 to quit)>150
Enter outstanding dep (0 to quit)>25
Enter outstanding dep (0 to quit)>0
Outstanding withdrawal (or 0 to quit)>57.85
Enter withdrawal (0 to quit)>200
Enter withdrawal (0 to quit)>50
Enter withdrawal (0 to quit)>125.38
Enter withdrawal (0 to quit)>0
Your final balance in your checkbook should be $ 169.62
Why is this happening it should be: 186.77
Code:
#include <stdio.h>
#define SENTINEL 0
float finbal, outdep, withdraw;
int main (void)
{
printf("BANK RECONCILIATION FOR: 10/21/98");
printf("\n\nEnding balance on statement:");
scanf ("%f", &finbal);
printf("Enter Outstanding dep (or %d to quit)>", SENTINEL);
scanf ("%f", &outdep);
while (outdep!= SENTINEL)
{
printf("Enter outstanding dep (%d to quit)>", SENTINEL);
scanf("%f", &outdep);
finbal = finbal + outdep;
}
printf("Outstanding withdrawal (or %d to quit)>", SENTINEL);
scanf ("%f", &withdraw);
while (withdraw!=SENTINEL)
{
printf("Enter withdrawal (%d to quit)>", SENTINEL);
scanf("%f", &withdraw);
finbal = finbal - withdraw;
}
/* the outstanding deposits and withdrawals, are already sub-totaled
into finbal. So this is all you need:
*/
printf("Your final balance in your checkbook should be $ %.2f\n" , finbal);
return 0;
}