-1

我正在用 C 编写一个程序来模拟支票账户。有交易代码,I = 初始余额,D = 存款,C = 支票(你给某人写一张支票,就像取款一样)。维护帐户的月费为 3.00 美元,每张兑现支票的费用为 0.06 美元,每笔存款为 0.03 美元,当兑现支票余额低于 0.00 美元时,透支费用为 5.00 美元。

我无法完成这些功能。如果您不认为对所有这些都有帮助,那么请帮助使用 deposit() 函数。我才刚接触 C 语言几个月,而我们刚刚接触到函数。这是我未完成的代码。谢谢你的帮助。

#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)
{



}
4

1 回答 1

0

当您声明/定义时,我只看到deposit(); 函数在您的函数中,您使用了五个参数,但调用时间仅使用了四个参数。

所以如果你打电话deposit (amount, &balance, &service, &numDeposit);

然后像这样更改您的定义/声明

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

}
于 2015-10-16T05:42:23.150 回答