-1

I am writing a program in C to simulate a checking account. There are codes for transactions, I = Initial Balance, D = Deposit, and C = Check(you write a check to someone, like a withdrawal). There is a monthly fee of $3.00 to maintain the account, $0.06 fee for every check cashed, %0.03 for every deposit made, $5.00 overdraft fee whenever a check cashed brings the balance below $0.00.

I am having trouble completing the functions. If you don't think helping a bit with all of them is ok then please just help with the deposit() function. I am only a couple months into C and we just got into functions. Here is my unfinished code. Thanks for any help.

#include <stdio.h>

void outputHeaders (void);
void initialBalance (double iBalance);
void deposit(double amount, double balance, double service, int numDeposit,double amtDeposit);
void check(char code, double amtCheck, double balance);
void outputSummary ();


int main (void)
{

char code;
double amount, service, balance;
double amtCheck, amtDeposit, openBalance, closeBalance;
int numCheck, numDeposit;

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();

printf("Enter the code of transaction and the amount: ");
scanf("%c %lf\n", &code, &amount);

if (code == 'I')
{
    initialBalance(amount, &balance, &service, &numDeposit, &amtDeposit);
}

else if (code == 'D')
{
    deposit (amount, &balance, &service, &numDeposit);  
}
else
{
    check(amount, &balance, &service, &numCheck, &amtCheck);
}


getchar(); getchar();
return 0;
}

void outputHeaders (void)
{

printf("Transaction         Deposit       Check      Balance\n"
       "--------------      --------      ------     -------");
}

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



}

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

*balance = *balance + *amtDeposit;  
*numDeposit++;                      //need to keep track of amount of deposits
*service = *service - 0.03;         //service charge

printf("Deposit %lf %lf\n", *amtDeposit, *balance);

}

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



}

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



}
Futbolero
  • 11
  • 1
  • 2
  • `I am having trouble completing the functions. ` Tell us what the problem is. "I don't know C" is out of scope for SO. – John3136 Oct 16 '15 at 05:17
  • @John3136 Sorry if it wasn't clear but I did ask for help with the deposit function. Is what I have correct? Will that code update the balance appropriately so it can be used for other transactions? – Futbolero Oct 16 '15 at 05:21
  • @Futbolero what is the issue you are facing in `deposit()` function? – Pawan Oct 16 '15 at 05:36
  • @Pawan I want to know if what I did is correct. Will the code update the balance appropriately so that the new balance can be used for future transactions? Not sure how to test it so I am asking so maybe someone with more knowledge and experience can correct me if Im wrong by just looking at it. And if it's correct, can I do the check() function in the same manner except I subtract since it's a withdrawal? – Futbolero Oct 16 '15 at 06:56

1 Answers1

0

I have seen only deposit(); function when you declared/defined In your function you are using five arguments but calling time used only four argument.

so if you are calling like deposit (amount, &balance, &service, &numDeposit);

Then change your definition/declaration like this

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

*balance = *balance + amount;  
*numDeposit++;                      //need to keep track of amount of deposits
*service = *service - 0.03;         //service charge
//I think service change need to reduce from main balance so
*balance = *balance - 0.03;
printf("Deposit %lf  balance %lf\n", amount, *balance);

}
Mohan
  • 1,871
  • 21
  • 34