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

Part 1 (separate solution): You don\'t need to round to the nearest penny, or al

ID: 3736258 • Letter: P

Question

Part 1 (separate solution):

You don't need to round to the nearest penny, or align the output into a table. So, this is OK too:
Please enter loan amount: 10000
Please enter annual interest rate as percent: 12
Please enter number payments: 36
Loan Amount: $10000
Monthly Interest Rate: 1
Number of Payments: 36
Monthly Payment: $332.143
Amount Paid Back: $11957.2
Interest Paid: $1957.15

The monthly payment on a loan may be calculated by the following formula: payment-(rate (1+rateN) ((1+RateyN-1)) *L Rate is the monthly interest rate, which is the annual interest rate divided by 12. (12 percent annual interest would be 1 percent monthly interest.) N is the number of payments and L is the amount of the loan. Write a program that asks for loan amount, annual rate, and number of payments and displays the following report: Loan Amount : $ 10 000. 00 Monthly Interest Rate: 1·00 Number of Payments : 36 Monthly Fayment: S 332.14 Amount Paid Back: $ 11957.15 Interest Paid: 1957.15 Please enter loan amount: 10000 Please enter annual interest rate as percent: 12 Please enter number payments: 36 Loan Amount: 10000.00 Monthly Interest Rate: 1.00 Number of 1957.15 Payments: 36 Monthly Payment 332.14 Amount Paid Back: S 11957.15 Interest Paid: You don't need to round to the nearest penny, or align the output into a table. So, this is OK too: Please enter loan amount: 10000 Please enter annual interest rate as percent: 12 Please enter number payments: 36 Loan Amount: Monthly Interest Rate 1 Number of Payments 36 MonthN Payment Amount Pald Back Interest Paid: $10000 $332.143 $11957.2 $1957.15

Explanation / Answer

#include <iostream>

#include <fstream>

#include <sstream>

#include <string>

#include <cstring>

#include <cmath>

using namespace std;

double findPaymentAmount( double loanAmount, double annualInterestRate, double numberOfPayments);

double findMonthlyInterestRate( double annualInterestRate);

double findPaymentAmount( double loanAmount, double annualInterestRate, double numberOfPayments){

double rate = findMonthlyInterestRate(annualInterestRate)/100;

double N = numberOfPayments;

double L = loanAmount;

double paymentAmount;

  

//payment = ((rate * (1+rate)^N) / ((1+Rate)^N - 1)) * L  

paymentAmount = ((rate * pow((1+rate),N)) / ( pow((1+rate),N )- 1)) * L ;

return paymentAmount;

}

double findMonthlyInterestRate(double annualInterestRate){

return annualInterestRate/12;

}

int main(){

double loanAmount, annualInterestRate, numberOfPayments, paymentAmount;

  

cout << "Please enter loan amount: " <<endl;

cin >> loanAmount;

cout << "Please enter annual interest rate as percent: " <<endl;

cin >> annualInterestRate;

cout << "Please enter number payments: " <<endl;

cin >> numberOfPayments;

cout << "Loan Amount: " << loanAmount << endl;

cout << "Monthly Interest Rate: " << findMonthlyInterestRate(annualInterestRate) << endl;

cout << "Number of Payments: " << numberOfPayments << endl;

paymentAmount = findPaymentAmount( loanAmount, annualInterestRate, numberOfPayments);

cout << "paymentAmount : " << paymentAmount <<endl;

cout << "Amount Paid Back : " << paymentAmount * numberOfPayments <<endl;

cout << "Interest Paid : " << paymentAmount * numberOfPayments - loanAmount <<endl;

  

}