Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you fix my code correctly? and how do you input account.txt to this file because otherwise, the output was account.text could not be

Can you fix my code correctly? and how do you input "account.txt" to this file because otherwise, the output was "account.text could not be opened for input.Program ended with exit code: 1. " Can you explain step by step? I'm using Xcode Version 9.4.1.

#include

#include

FILE *fpIn,*fpOut;

void outputHeaders(void);

void initilBalance(double amount, double *balance, double *service, double *openBalance) ;

void deposit(double amount,double *balance, double *service, int *numDeposit, double *amtDeposit);

void check(double amount,double *balance, double *service, int *numCheck, double *amtCheck);

void outputSummary(int numDeposit,double amtDeposit, int numCheck, double amtCheck, double openBalance,double service, double closeBalance);

void outputHeaders(void){

printf("%10s%15s%15s%15s ", "Transaction", "Deposit", "Check", "Balance");

printf("%10s%15s%15s%15s ", "---", "-------", "-------", "-------");

}

void initialBalance(double amount, double *balance, double *service, double *openBalance){

*balance = amount;

*service =3.00;

*openBalance = amount;

fprintf(fpOut, "Initial Balance %.2lf ", *openBalance);

}

void deposit(double amount,double *balance, double *service, int *numDeposit, double *amtDeposit){

*balance+=amount;

*service=*service+0.03;

*numDeposit+=1;

*amtDeposit+=amount;

fprintf(fpOut, "Deposit \t%.2lf\t \t%.2lf ", amount, *balance);

}

void check(double amount,double *balance, double *service, int *numCheck, double *amtCheck){

if(amount

*balance-=amount;

*service=+0.06;

}

else if(*balance

*service+=5.00;

}

*numCheck+=+1;

*amtCheck+=amount;

fprintf(fpOut, "Check\t \t%.2lf\t %.2lf ", amount, *balance);

}

void outputSummary(int numDeposit,double amtDeposit, int numCheck, double amtCheck, double openBalance,double service, double closeBalance){

printf("Total number deposits: %d ",numDeposit);

printf("Total amount deposits: %f ",amtDeposit);

printf("\tTotal number checks: %d ",numCheck);

printf("\tTotal amount checks: %f ",amtCheck);

printf("Total service charge: %f ",service);

printf("\t\t Opening Balance: %f ",openBalance);

printf("\t\t Closing Balance: %f ",closeBalance);

}

int main(void) {

char code;

double amount, service, balance;

double amtcheck, amtDeposit, openBalance, closeBalance;

int numCheck, numDeposit;

if (!(fpIn = fopen("account.txt","r"))) {

printf("account.text could not be opened for input.");

exit (1);

}

if (!(fpOut = fopen("csis.txt","w"))) {

printf("csis.text could not be opened for output.");

exit (1);

}

amount = 0.0;

service = 0.0;

balance = 0.0;

amtcheck = 0.0;

amtDeposit = 0.0;

openBalance =0.0;

closeBalance = 0.0;

numCheck = 0;

numDeposit = 0;

outputHeaders ();

while (!feof(fpIn))

{

fscanf(fpIn, "%c %lf ", &code, &amount);

if (code == 'I') {

initialBalance (amount, &balance,&service,&openBalance);

}

else if (code == 'D'){

deposit(amount,&balance,&service,&numDeposit,&amtDeposit);

}

else{

check( amount,&balance,&service,&numDeposit,&amtDeposit);

}

closeBalance = balance - service;

outputSummary(numDeposit, amtDeposit, numCheck,amtcheck,openBalance,service,closeBalance);

fclose(fpIn);

fclose(fpOut);

return 0;

}

}

This is the problem that I have to follow.

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Thank you.

Checking Account Lab Construct a C program, check.c, that reads the details of a monthly checking account and outputs a bank statement summarizing these transactions. An input ile, account.txt, contains a list of transactions for the checking account for one month. Each line of the input file consists of a one-character transaction code along with a double containing the amount of the transaction. Valid transaction codes are as follows: I Initial balance brought forth from previous month D Deposit C Check As each transaction is entered, you should output on a single line the type of transaction, the amount of the transaction (separate columns for deposits and checks), and the balance after the transaction has been processed: Transaction Deposit Check Balance Initial Balance Deposit Deposit Check Check 478.83 606.28 1226.12 281.00 276.24 127.45 619.84 945.12 4.76 The bank's service charges (which should be deducted from the balance at the end of the month) are as follows: $3.00 per month to maintain the account. $0.06 for each check cashed. $0.03 for each deposit made. 55.00 overdraft whenever a check cashed brings the balance below s0.00. Note: Do not assess the overdraft service charge when the transaction is a deposit into an overdrawn account that does not bring the balance above zero. Page 23

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Application Development And Design

Authors: Michael V. Mannino

1st Edition

0072463678, 978-0072463675

More Books

Students also viewed these Databases questions

Question

=+For a different audience? In another tone of voice?

Answered: 1 week ago

Question

4. Show the trainees how to do it again.

Answered: 1 week ago