使用功能显示帐户所有者余额 [英] Using functions to display an account owners balance

查看:71
本文介绍了使用功能显示帐户所有者余额的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.我在遇到困难时遇到了困难.我需要使用一个名为voidDisplayBalance的函数来显示帐户所有者每月欠的余额.这是问题所在:

无息信贷公司向客户提供零息贷款. (它通过在月度报表中出售广告空间并出售其客户列表来获利.)设计一个应用程序,该应用程序将获取包括帐号,客户名和到期余额的客户帐户数据.对于每个客户,显示帐号和姓名;然后在接下来的10个月中每月打印客户的预计余额.假设此帐户没有任何财务费用,客户没有进行新的购买,并且客户以相等的每月付款(即原始账单的10%)还清余额.
将该文件命名为lab6a.

您需要实现以下功能:

void dipslayBalance(int account_number,char name [],float balance)
该功能显示帐号和名称;然后在接下来的10个月中每月打印客户的预计余额


样本输出

输入帐号(-1终止输入):
123
输入姓名:John Nguyen
输入到期余额:
10000.00

帐号:123
姓名:John Nguyen

MONTH BALANCE DUE
1 9000.00
2 8000.00
3 7000.00
4 6000.00
5 5000.00
6 4000.00
7 3000.00
8 2000.00
9 1000.00
10 0.00

输入帐号(-1终止输入):
456
输入名称:Jose Hernandez
输入到期余额:
25000.00

帐号:456
姓名:Jose Hernandez

MONTH BALANCE DUE
1 22500.00
2 20000.00
3 17500.00
4 15000.00
5 12500.00
6 10000.00
7 7500.00
8 5000.00
9 2500.00
10 0.00

输入帐号(-1终止输入):
-1
谢谢.

这是我到目前为止的内容:

Hello all. I am having some difficult time with my problem. I need to use a function called voidDisplayBalance to display the balance an account owner owes each month. Here is the problem:

The No Interest Credit Company provides zero-interest loans to customers. (It makes a profit by selling advertising space in its monthly statements and selling its customer lists.) Design an application that gets customer account data that includes an account number, customer name, and balance due. For each customer, display the account number and name; then print the customer’s projected balance each month for the next 10 months. Assume that there is no finance charge on this account, that the customer makes no new purchases, and that the customer pays off the balance with equal monthly payments, which are 10 percent of the original bill.
Name the file as lab6a.

You are required to implement the following function:

void dipslayBalance(int account_number, char name[ ], float balance)
The function displays the account number and name; then print the customer’s projected balance each month for the next 10 months


Sample output

Enter Account Number (-1 to terminate the input):
123
Enter name: John Nguyen
Enter balance due:
10000.00

Account Number: 123
Name: John Nguyen

MONTH BALANCE DUE
1 9000.00
2 8000.00
3 7000.00
4 6000.00
5 5000.00
6 4000.00
7 3000.00
8 2000.00
9 1000.00
10 0.00

Enter Account Number (-1 to terminate the input):
456
Enter name: Jose Hernandez
Enter balance due:
25000.00

Account Number: 456
Name: Jose Hernandez

MONTH BALANCE DUE
1 22500.00
2 20000.00
3 17500.00
4 15000.00
5 12500.00
6 10000.00
7 7500.00
8 5000.00
9 2500.00
10 0.00

Enter Account Number (-1 to terminate the input):
-1
Thank you.

Here is what I have so far:

#include <iostream>
#include <iomanip>
using namespace std;

void displayBalance(int, char[], float);

int main()
{
	int accntNum;	//Variable account number.
	char name[26];	//Name of account owner.
	float bal;		//Balance owner of account owes each month.
	int balDue;		//Variable balanceDue.
		for(bal=10000.00;bal<=balDue;bal-=1000.00)
	{
	cout << "Enter Account Number (-1 to terminate the input):\n";
	cin >> accntNum;
	
	if(accntNum==-1)
		cout << "Thank you.\n";

		else
	{
	cout << "Enter name:";
	cin >> name;
	cout << "Enter balance due:\n";
	cin >> bal;
}
	displayBalance(accntNum, name, bal);
	}
	return 0;
}

	void displayBalance(int accntNum, char name[], float bal)
	{
		if(bal==10000.00)
		{
		bal=bal-1000.00;
		cout << "Account Number: " << accntNum << endl;
		cout << "Name: " << name << endl;
		cout << left << setw(12) << "\nMONTH" << right << "BALANCE DUE" << setw(4) << setprecision(2) << fixed << endl;
		cout << left << setw(12) << "1" << right << bal << setw(4) << endl;
		cout << left << setw(12) << "2" << right << bal << setw(4) << endl;
		cout << left << setw(12) << "3" << right << bal << setw(4) << endl;
		cout << left << setw(12) << "4" << right << bal << setw(4) << endl;
		cout << left << setw(12) << "5" << right << bal << setw(4) << endl;
		cout << left << setw(12) << "6" << right << bal << setw(4) << endl;
		cout << left << setw(12) << "7" << right << bal << setw(4) << endl;
		cout << left << setw(12) << "8" << right << bal << setw(4) << endl;
		cout << left << setw(12) << "9" << right << bal << setw(4) << endl;
		cout << left << setw(12) << "10" << right << bal << setw(4) << endl;
	}
}



出现的问题:

1.运行程序时,即使输入-1,它也不会停止执行.

2.当我在cin>>下输入10000.00时, bal,所有月份的输出在"BALANCE DUE"下显示9000.00.我究竟做错了什么?我想我在某处包括了太多的括号.



Problems that are occuring:
It
1. When I run the program, it does not stop executing, not even when I enter -1.

2. When I enter 10000.00 under cin >> bal, the output displays 9000.00 under "BALANCE DUE" for all months. What am I doing wrong? I think I am including one too many brackets somewhere. Is it in my "for-loop"?

推荐答案

for(bal=10000.00;bal<=balDue;bal-=1000.00)


这句话该怎么办?另请注意,balDue尚未初始化,因此将不包含有效内容.


What is this statement supposed to do? Also note that balDue has not been initialised and so will not contain valid content.


这篇关于使用功能显示帐户所有者余额的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆