Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am using C++ to build a loan calculator. I have already started the project, a

ID: 3867276 • Letter: I

Question

I am using C++ to build a loan calculator. I have already started the project, and just need a little more work to get it finished. The link to my file is below the program specifications. The specifications are as follows...

Loan Calculator

            For this program you are going to create a loan calculator which uses a separate class to calculate a monthly loan payment (and schedule), given a principal amount (i.e., amount borrowed), annual interest rate, and a term (in months). The formula for this calculation is fairly straightforward:

                                   __                                                __

Monthly           =          |Rate +     _______Rate________ | * Principal

Payment                       |           ((1 + Rate) ^ Months) - 1 |

                                    |__                                              __|

In words: Payment = (Rate + (Rate divided by ((1 plus Rate) to the power of the months) minus 1) all times the principal). Rate must be expressed as a per month value (i.e., annual rate in decimal form, divided by 12).

Your program should clearly indicate what form the input values should take, and it should verify that the values received are within expected parameters; in this case, it means all values are positive, and the interest rate is between zero and 0.25. In addition, the program should be able to ask for several scenarios – only terminating when a zero is entered for Principal. After each payment calculation, the operator should be given a chance to display a month-by-month amortization of the loan (see example below), and then asked if s/he wishes to save the loan scenario. All calculations for the Loan: monthly payment and all schedule values, are to be generated by a separate Loan class, which is instantiated after the required starting values have been entered.

===================================================================

Welcome: this program calculates monthly payments based on principal, interest and term values.

Please enter your Principal amount (no commas, 0 to Quit): 30000

Please enter your Annual Interest Rate (.06 = 6%): .065

Please enter your Term (in months): 60

A monthly payment of $586.98 is required to pay off a $30000 loan in 60 months at a 6.5% rate.

Would you like to see the amortization schedule (Y/N)? N

Save loan scenario? (Y/N): N

Please enter your Principal amount (no commas, 0 to Quit): 125000

Please enter your Annual Interest Rate (.06 = 6%): .06

Please enter your Term (in months): 360

A monthly payment of $749.44 is required to pay off a $125000 loan in 360 months at a 6.0% rate.

Would you like to see the amortization schedule (Y/N)? N

Save loan scenario? (Y/N): N

Please enter your Principal amount (no commas, 0 to Quit): 5000

Please enter your Annual Interest Rate (.06 = 6%): .09

Please enter your Term (in months): 12

A monthly payment of $437.26 is required to pay off a $5000 loan in 12 months at a 9.0% rate.

Would you like to see the amortization schedule (Y/N)? Y

                  Beginning                                                             Ending

Month       Principal               Pmt                 Interest              Balance

1

    $5,000.00

$437.26

$37.50

$4,600.24

2

$4,600.24

$437.26

$34.50

$4,197.49

3

$4,197.49

$437.26

$31.48

$3,791.71

4

$3,791.71

$437.26

$28.44

$3,382.89

5

$3,382.89

$437.26

$25.37

$2,971.01

6

$2,971.01

$437.26

$22.28

$2,556.03

7

$2,556.03

$437.26

$19.17

$2,137.94

8

$2,137.94

$437.26

$16.03

$1,716.72

9

$1,716.72

$437.26

$12.88

$1,292.34

10

$1,292.34

$437.26

$9.69

$864.77

11

$864.77

$437.26

$6.49

$434.00

12

$434.00

$437.26

$3.26

$0.00

Save scenario (Y/N): Y

File Name: loan1.txt

Loan scenario has been saved in file loan1.txt

Please enter your Principal amount (no commas, 0 to Quit): 0

Thanks for using the Payment Calculator!

===================================================================

As seen above, after a schedule is (or is not) produced, the program asks the user if they wish to save the loan scenario. If they answer yes (see last example above), they are then prompted for a file name under which the loan will be saved. This file name given is then sent to a save function inside the Loan class, which creates the file and writes 4 text lines into it with the following values (in order):

            Principal Amount

            Annual Interest Rate

            Term (in months)

            Monthly Payment amount

Again, since you are doing this in object oriented style, note that all the monthly schedule values: beginning balance, interest charge, ending balance, monthly payment, and save operation come from functions in the separate Loan class. The ‘main’ program requests user input, validates, and instantiates the Loan class, and then calls the loan class functions to produce the monthly payment and schedule values. The specific function names are left for you to choose.

Call your project loanCalc and submit the Visual Studio C++ project (full project)

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Here is a link to my starting file

https://1drv.ms/u/s!AjLswKvo9tl3hC7jHH99H2lB8keG

1

    $5,000.00

$437.26

$37.50

$4,600.24

2

$4,600.24

$437.26

$34.50

$4,197.49

3

$4,197.49

$437.26

$31.48

$3,791.71

4

$3,791.71

$437.26

$28.44

$3,382.89

5

$3,382.89

$437.26

$25.37

$2,971.01

6

$2,971.01

$437.26

$22.28

$2,556.03

7

$2,556.03

$437.26

$19.17

$2,137.94

8

$2,137.94

$437.26

$16.03

$1,716.72

9

$1,716.72

$437.26

$12.88

$1,292.34

10

$1,292.34

$437.26

$9.69

$864.77

11

$864.77

$437.26

$6.49

$434.00

12

$434.00

$437.26

$3.26

$0.00

Explanation / Answer

I belive this question has been already answered once still answering again . Chhers :)

#include <iostream>

#include <math.h>

#include <stdlib.h>
#include <fstream>
#include <iomanip>

using namespace std;

class Loan
{
private:
float principal;
float rate;
float term;
float monthlyPayment;

public:
  
Loan(float principal, float rate, float term) {
this->principal = principal;
this->rate = rate;
this->term = term;
this->monthlyPayment = 0;
}

void CalcMonthlyPayout()
{
float monthRate = (this->rate/12);

this->monthlyPayment = monthRate * pow (( 1.0 + monthRate ), this->term) * this->principal/ (pow(( 1.0 + monthRate), this->term) -1.0);
  
}
void DisplayMonthlyPayout()
{   
cout.setf(ios_base::fixed , ios_base::floatfield);
cout.precision(2);
cout << "A monthly payment of $"<<monthlyPayment<<" is required to pay off a $"<<this->principal<<" loan in "
<<this->term<<" months at a "<<this->rate*100<<"% rate"<<endl;
}

void Amortization() {

cout << "Month Beginning Principal Pmt Interest Ending Balance"<<endl;
float interest;
float begBal = this->principal;
float endBal;

for(int i = 1 ; i<= (int)this->term ; i++) {
interest= begBal * rate /12 ;

endBal = begBal - this->monthlyPayment + interest;
cout <<i<<" "<<begBal<<" "<<this->monthlyPayment<<" "<<interest<<" "<<endBal<<endl;
begBal = endBal;

}
  
}

void SaveScenario(char *file){
ofstream outfile;
//enter path here
outfile.open((file));
outfile << principal <<" " << rate <<" " <<term <<" " <<monthlyPayment <<" ";
cout<<"Loan scenario has been saved in file"<<file;
outfile.close();
}
};

int main()
{
float principal;
float rate;
float term;
int choice;

cout << "Please enter your Principal amount (no commas, 0 to Quit)" << endl;
cin>>principal;
cout << "Please enter your Annual Interest Rate (.06 = 6%)" << endl;
cin>>rate;
cout << "Please enter your Term (in months)" << endl;
cin>>term;
Loan loan(principal, rate, term);
loan.CalcMonthlyPayout();
loan.DisplayMonthlyPayout();
cout<<"Would you like to see the amortization schedule (1. Yes/2. No)?"<<endl;
cin>>choice;

if(choice == 1) {
loan.Amortization();

cout<<"Save scenario (1. Yes/2. No)?"<<endl;
cin>>choice;
cin.ignore();
if(choice == 1) {
char fileName[256];
cout<<"File Name:"<<endl;
cin.getline(fileName ,256);
loan.SaveScenario(fileName);
}
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote