I am currently working on a homework assignment I am having a hard time adding the last value from a while loop :
Code:while (!feof(fp)) { fscanf(fp, "%c %f\n", &code, &amount); if(code == 'I') { printf("Initial Balance %.2f\n",amount); intitial_balance = amount; } if (code == 'D') { deposit = amount + intitial_balance; printf("Deposit $%.2f $%.2f\n",amount,deposit); intitial_balance = deposit; depositcounter++; } if (code == 'C') { cashcheck = intitial_balance - amount; printf("Check Cash $%.2f $%.2f\n",amount,cashcheck); intitial_balance = cashcheck; if (intitial_balance < 0.00 ) { overdraft++; } } } printf(" There were %d Deposits width the Amount of %4.2f with the deposits\n",depositcounter,deposit_oa1);
I have everything I need but there is just one thing that I can't figure out and it's how to get the over all number in deposit and checks cashed . Meaning adding all the deposits , like if my first deposit was 144.35 then the next one is 166.88 I have to add them.
I hope this makes sense .....



LinkBack URL
About LinkBacks


