Code:
#include <stdio.h>
float wd(float*, char*[], float*);
float dep(float*, char*[], float*);
float bpm(float*, char*[], float*);
void PrintResults(float, float, float, float, int, int, int, char[], char[], char[], float, float, float);
void main(void)
{
float balance, wd1, dep1, bpm1, wdbal, depbal, bpmbal;
char junk, cont, wddate[15], depdate[15], bpmdate[15], trans1[5], trans2[5], trans3[5];
int trans;
printf("Please type the last balance as float: \n");
scanf("%f", &balance);
scanf("%c", &junk);
printf("Transactions \n");
printf("Please type Y to continue or N to stop: \n");
scanf("%c", &cont);
while (cont != 'N')
{
printf("Please type 1 for Withdrawl, 2 for deposit, or 3 for Bill Payment \n");
scanf("%d", &trans);
if (trans == 1)
{
wdbal = wd(&balance, &wddate, &wd1);
trans1 = "wd";
}
else if (trans == 2)
{
depbal = dep(&balance, &depdate, &dep1);
trans2 = "dep";
}
else if (trans == 3)
bpmbal = bpm(&balance, &bpmdate, &bpm1);
trans3 = "bpm";
}
else
printf("Unknown transaction type \n");
scanf("%c", &junk);
printf("Please type Y to continue or N to stop: \n");
scanf("%c", &cont);
}
PrintResults(wdbal, depbal, bpmbal, balance, trans1, trans2, trans3, wddate, depdate, bpmdate, wd1, dep1, bpm1)
}
float wd(float *balance, char *wddate[], float *wd1)
{
printf("Please enter the date of withdrawl \n");
scanf("%s", &wddate);
float wdbal;
printf("Please enter the amount to withdrawl: \n");
scanf("%f", &wd1);
wdbal = balance - wd1;
balance = balance - wd1;
return wdbal;
}
float dep(float *balance, char *depdate[], float *dep1)
{
printf("Please enter the date of deposit \n");
scanf("%s", &depdate);
float depbal;
printf("Please enter the amount to deposit: \n");
scanf("%f", &dep1);
depbal = balance + dep1;
balance = balance + dep1;
return depbal;
}
float bpm(float *balance, char *bpmdate[],float *bpm1)
{
printf("Please enter the date of bill payment \n");
scanf("%s", &depdate);
float bpm1, bpmbal;
printf("Please enter the amount to be paid to bills: \n");
scanf("%f", &bpm1);
depbal = balance - bpm1;
balance = balance bpm1;
return bpmbal;
}
void PrintResults(float wdbal, float depbal,float bpmbal,float balance,char trans1[],char trans2[],char trans3[],char wddate[],char depdate[],char bpmdate[], float wd1, float dep1, float bpm1)
{
printf("Date Type Amount Balance");
printf("%s %s $%.2f $%.2f \n", wddate, trans1, wd1, wdbal);
printf("%s %s $%.2f $%.2f \n", depdate, trans2, dep1, depbal);
printf("%s %s $%.2f $%.2f \n", bpmdate, trans3, bpm1, bpmbal);
printf("\n");
printf("Current balance: $%.2f", balance);
}
the program is supposed to first take the balance in a bank account, then ask if there are transactions, if yes it goes into the loop and asks what type of transactions. When a type is entered the specific funtion is supposed to take place and then the balance's are returned. After there are no more transactions the print function is to take place. However, I have a lot of errors and we were never really taught as to what they meant. I will list the errors: