Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is my code for a homework problem. I am confused on what to fill the functi

ID: 642108 • Letter: T

Question

This is my code for a homework problem. I am confused on what to fill the functions with. Am i taking information from one text file and returning and adding more information to the output file. I understand that the functions will calculate on the variables passed through the functions, i just don't know how to do that / write it.

#include <stdio.h>
#include <stdlib.h>

FILE *fp, *csis; /// file pointer for input and csis for output


double intitalBalance(amount, balance, service, openBalance);               ///// Function Prototyping
double deposit(amount, balance, service, numDeposit, atmDeposit);
double check(amount, balance, service, numCheck, atmCheck);
double outputSummary(numDeposit, atmDeposit, numCheck, atmCheck, openBalance, service, closeBalance);
void outputHeaders(void);


int main(void){

   char code;
   double amount, service, balance;
   double atmCheck, atmDeposit, openBalance, closeBalance;
   int numCheck, numDeposit;

   if (!(fp = fopen("account.txt", "r"))){                       //////// Read File ///////
       printf("account.txt could not be found.");
       exit(1);
   }  
   if (!(csis = fopen("csis.txt", "w"))){
       printf("csis.txt could not be found.");               //////// Output File ///////
       exit(1);
   }

   amount = 0.0;
   service = 0.0;
   balance = 0.0;                                   //////// Delcared Variables///////
   atmCheck = 0.0;
   atmDeposit = 0.0;
   openBalance = 0.0;
   closeBalance = 0.0;
   numCheck = 0;
   numDeposit = 0;

   outputHeaders();

   while (!feof(fp)){

       fscanf(fp, "%c %lf ", &code, &amount);
       if (code == 'I'){
           intitalBalance(amount, &balance, &service, &openBalance);
       }
       else if (code == 'D'){
           deposit(amount, &balance, &service, &numDeposit, &atmDeposit);
       }
       else{
           check(amount, &balance, &service, &numCheck, &atmCheck);
       }
   }
   closeBalance = balance - service;
   outputSummary(numDeposit, atmDeposit, numCheck, atmCheck, openBalance, service, closeBalance);

   fclose(csis);
   fclose(fp);
   return;

}

double intitalBalance(amount, balance, service, openBalance){
  

}

double deposit(amount, balance, service, numDeposit, atmDeposit){

   return(balance);
}

double check(amount, balance, service, numCheck, atmCheck){

   return(balance);
}

double outputSummary(numDeposit, atmDeposit, numCheck, atmCheck, openBalance, service, closeBalance){

   printf("Total Number deposits: %d ", numDeposit);
   printf("Total Amount deposits: %.2lf ", atmDeposit);

   printf("Total Number checks: %d ", numCheck);
   printf("Total Amount checks: %.2lf ", atmCheck);

   printf("Total Service Charge: %.2lf ", service);

   printf("Opening Balance: %.2lf ", openBalance);
   printf("Closing Balance: %.2lf ", closeBalance);


   return(service);
}

void outputHeaders(void){
   printf("Transaction Deposit Check Balance ");
  
   int i;

   for (i = 1; i <= 50; i++){

       printf("%c", '-');
   }
   printf(" ");
  
}

Explanation / Answer

Your code is with all error please change the code to this format

#include
#include

void writeintofile(int accountnumber,String name,int dob,float initialdeposit,String accounttype,int balance)
{
File *fp;
fp=fopen("account.txt","w");
if(fp==NULL)
printf(" Couldnot open account.txt for writing");


void main()
{

int o;
clrscr();
do
{
printf(" Please Select The Option");
printf(" 1.New Account ");
printf(" 2.Cash Withdrawl");
printf(" 3.Balance Inquiry");
printf(" 4.Deposit");
printf(" 5.Quit");
printf(" Summary");
scanf("%d",&o);

switch(o)
{
int dob;
float accountnumber,initialdeposit,balance;
char name[25],accounttype[25];
case 1:
{
printf("Enter accountnumber");
scanf("f",&accountnumber);
printf(" Enter Name");
scanf("%s",&name);
printf(" Enter DOB");
scanf("%d",&dob);
printf(" Enter initialdeposit");
scanf("%f",&initialdeposit);
printf(" Enter accounttype:");
scanf("%s",&accounttype);
printf(" Enter Balance");
scanf("%f",&balance);
writeintofile(accountnumber,name,dob,initialdeposit,accounttype,balance);

break;

}

case 2:

printf("Enter account no:");

//Open file....


}
while(o==5);
getch();
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote