Financial Calculator: You will develop a program for a bank that will allow it t
ID: 3869378 • Letter: F
Question
Financial Calculator: You will develop a program for a bank that will allow it to process loans for customers. The user will enter information, such as interest rate, length of loan, amount borrowed, or desired payment, and the program will compute the missing information. It will also be able to display a report showing the amortization schedule for the loan. Customer data should be able to be saved and retrieved from a file or files. Your final project must include all of the following. Your initial submission will start simple, and you will add features each week. Input and output Use of variables Use of conditional statements Use of loops Use of modules Use of arrays Ability to save and retrieve data
Explanation / Answer
#include <bits/stdc++.h>
using namespace std;
int main()
{
double monthlyPayment;
double balance;
double interestRate;
ofstream myfile;
myfile.open ("bank.txt");
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout << "Enter the current balance of your loan: $";
cin >> balance;
cout << "Enter the interest rate (compounded monthly) : ";
cin >> interestRate;
cout << "Enter the desired monthly payment : $";
cin >> monthlyPayment;
while (interestRate >= 1)
{
interestRate = interestRate / 100;
}
balance = balance * (1 + interestRate / 12) - monthlyPayment;
cout << "Your new balance is : $" << balance << endl;
myfile<<"Your new balance is : $" << balance << endl;
while (balance >0)
{
balance = balance * (1 + interestRate / 12) - monthlyPayment;
cout << "Your balance is now : $" << balance << endl;
myfile << "Your balance is now : $" << balance << endl;
}
cout << "You have paid off the loan at this point. Congratulations!";
myfile << "You have paid off the loan at this point. Congratulations!";
myfile.close();
string line;
cout<<" Reading file ";
ifstream fin( "bank.txt");
if ( !fin )
{
cout << "Error! Incorrect file."
<< endl;
exit( EXIT_FAILURE );
}
getline( fin, line );
while ( !fin.eof() )
{
getline( fin, line);
cout << line<<endl;
}
return 0;
}
======================================================
Enter the current balance of your loan: $2000
Enter the interest rate (compounded monthly) : 2
Enter the desired monthly payment : $200
Your new balance is : $1803.33
Your balance is now : $1606.34
Your balance is now : $1409.02
Your balance is now : $1211.36
Your balance is now : $1013.38
Your balance is now : $815.07
Your balance is now : $616.43
Your balance is now : $417.46
Your balance is now : $218.15
Your balance is now : $18.52
Your balance is now : $-181.45
You have paid off the loan at this point. Congratulations!
Reading file
Your balance is now : $1606.34Your balance is now : $1409.02Your balance is now : $1211.36Your balance is now : $1013.38Your balance is now : $815.072Your balance is now : $616.431Your balance is now : $417.458Your balance is now : $218.154Your balance is now : $18.5176Your balance is now : $-181.452You have paid off the loan at this point. Congratulations!
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.