how stupid of me I accidently erased something front the top sorry guys
the assignment I am doing is a checking account which gets the inputs from an external source ( and txt file) the txt file has a starting character which Id's what type of transaction
( I = initial Balance , D = Deposit , C = Checks cashed) . and then is has the number either depositing or taking away.
Example of txt file :
I 498.98
D 866.79
C 289.98
what the professor wants us to do is to make a monthly statement and produce a list of the transactions and the balance of the account
Transaction Deposits Checks Cashed Balance
Initial Balance 498.98
Deposit 1.00 1.00
Check Cashed 10.00 488.98
also wants us to output the how many deposits and check cashed , also to total how much money was deposited and taking away.
Where I am having trouble is in adding all the values from Deposit and check cashed the while loops the code and the amount. I got the initial balance taking care of but just adding up all the values in deposit and checks cashed to get the amount
I hope this helps
and here is my source code
Code:
#include <stdio.h>
FILE *fp;
int main(void)
{
int depositcounter =0;
float deposit;
float intitial_balance;
float temp_deposit[30];
int overdraft = 0;
float deposit_overall;
int deposit_trigger=0;
float deposit_oa1;
int i;
float deposit_oa2;
float cashcheck;
char code;
float amount;
fopen_s(&fp, "account.txt", "r");
printf("Transaction Deposit Cashed Checks Balance\n\n");
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 (deposit_trigger == 0)
{
}
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);
printf("There Are %d Overdraft\n",overdraft);
return 0;
}