WRITE IT IN C LANGUAGE Your program is to present the user w
WRITE IT IN C++ LANGUAGE
Your program is to present the user with a menu that offers the following options:
1. Set principal
2. Set annual interest
3. Set number of years
4. Amortization schedule
5. Exit
The menu should be redisplayed after each menu option 1-4 is successfully executed.
Along with the menu options, the current values for principal, annual interest, and number of years should be displayed. The monthly payment amount should also be displayed IF the annual interest rate and number of years are non-zero. If either are zero, a value for the monthly payment should not be displayed. Run the sample executable for this assignment to see the expected behavior.
If the user selects any one of the set options (#1-#3) from the menu, they should be prompted for a new value that takes the place of the current value.
Solution
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include \"hw3.h\"
using namespace std;
int main()
{
string Fname, Lname;
double loanAmount;
double annualIntRate, MonIntRate=0;
int No_of_Months;
welcome();
getCustomerInfo(Fname, Lname);
getLongInfo(loanAmount, annualIntRate, No_of_Months);
MonthlyInterestRateCalculator(annualIntRate);
MonthlyPmtCalculator(annualIntRate, loanAmount, No_of_Months, MonIntRate);
AmortizedTable(loanAmount, annualIntRate, No_of_Months);
return 0;
}
for the header file
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
#ifndef HW_3_HEAD_H
#define HW_3_HEAD_H
void welcome()
{
cout << \"Welcome to Rio Grande Bank \"<<endl;
cout << \"We are please in assisting you in your banking needs\" <<endl;
}
string getCustomerInfo(string Fname, string Lname)
{
string fullname;
cout << \"Enter your first name and last name:\";
cin>> Fname>>Lname;
fullname = Fname + Lname;
return fullname;
}
void getLongInfo(double& loanAmount, double& annualIntRate, int& No_of_Months)
{
cout << \"Enter the loan amount that you wish to borrow:\" <<endl;
cin>>loanAmount;
cout << \"Enter the annual interest rate: \";
cin>>annualIntRate;
cout << \"Enter the length of months of the loan \";
cin>>No_of_Months;
}
double MonthlyInterestRateCalculator(const double annualIntRate)
{
double MonIntRate;
MonIntRate = (annualIntRate/100)/12;
return MonIntRate;
}
double MonthlyPmtCalculator(double annualIntRate, const double loanAmount, const double MonIntRate, const int No_of_Months)
{
double MonthPmt;
MonthPmt = loanAmount * MonIntRate/(1 - pow(1 + MonIntRate, -No_of_Months));
return MonthPmt;
}
void AmortizedTable(const double loanAmount, const double annualIntRate, const int No_of_Months)
{
double balance, monthlyPaidInt, MonthPrincipal, MonIntRate, MonthPmt, newBalance;
MonIntRate = MonthlyInterestRateCalculator(annualIntRate);
MonthPmt = MonthlyPmtCalculator(loanAmount, MonIntRate, No_of_Months, annualIntRate);
balance = loanAmount;
cout <<\"\\t Amortized Payment Schedule\" <<endl;
cout <<setw(6)<<left<<\"Month\"<<setw(12)<<left<<\"Paid Principal\"<<setw(14)<<right<<\"Paid Interest\"<<setw(12)<<right<<\"New Balance\"<<endl;
for (int i=1; i <= No_of_Months; i++)
{
monthlyPaidInt = balance * MonIntRate;
MonthPrincipal = MonthPmt - monthlyPaidInt;
newBalance = balance - monthlyPaidInt;
cout <<setw(6)<<left<<i<<setw(12)<<left<<MonthPrincipal<<setw(4)<<right<<monthlyPaidInt<<setw(14)<<right<<newBalance<<endl;
}
}
#endif


