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; char name[26]; float bal; int balDue; 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;
}
}
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"?