我正在用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)
{
}
答案 0 :(得分: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);
}