المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : calculation error



C++ Programming
10-15-2009, 05:21 AM
hello, i am having a problem with this code. I do not know what is wrong. I enter the begbal, the ourdep and the withdraw. But in the end when goes to get the final balance. The answer is always the same as the input of begin bal. Any help would be greatful.

#include



#define SENTINEL 0

float endbal,
finbal;
int date,
outdep,
withdraw;

int main (void)


{

printf("BANK RECONCILIATION FOR: 10/21/98");

printf("\n\nEnding balance on statement:");
scanf ("%f", & endbal);


printf("Enter Outstanding dep (or %d to quit)>", SENTINEL);
scanf ("%d", & outdep);

while (outdep!= SENTINEL)
{
finbal = finbal + outdep;
printf("Enter outstanding dep (%d to quit)>", SENTINEL);
scanf("%f", & outdep);

}

printf("Outstanding check/withdrawal (or %d to quit)>", SENTINEL);
scanf ("%d", & withdraw);

while (withdraw!=SENTINEL)
{
finbal = finbal - withdraw;
printf("Enter withdrawal (%d to quit)>", SENTINEL);
scanf("%f", & withdraw);

}

finbal = endbal + outdep - withdraw;

printf("Your final balance in your checkbook should be $ %f" , finbal);

return 0;

}