Question: Please help with code not getting proper numbers. Monthly payment is good. interest on chart/layout is way off. principle on chart is way off. total

 Please help with code not getting proper numbers. Monthly payment is

good. interest on chart/layout is way off. principle on chart is way

off. total payments is o.k.. total interest is way off on chart.

Please help with code not getting proper numbers. Monthly payment is good. interest on chart/layout is way off. principle on chart is way off. total payments is o.k.. total interest is way off on chart.

#include #include #include #include #include

using namespace std;

void Getinput(double& P, double& r, int& n);

double MPay_formula (double P, double r, int n); //function that will compute M=P((r*(1+r)^n)/(((1+r)^n)-1)

void intPrinciple(double M, double P, double r, int n, double &interest, double &principal, double &balance); // calculates interest and balance for every month.

void totPaymentInterest(double M, double& totpayment, double& totinterest, double& interest); // keeps track of total payment and total interest accumulated.

void printresults(double m, double P, double r, int n, double interest, double principal, double balance, double totpayment, double totinterest);

int main() {

double P = 0, r = 0, interest, principal, balance, totpayment = 0, totinterest = 0; int n; cout

double M = MPay_formula (P, r / 12, n); cout

intPrinciple( M, P, r / 12, n, interest, principal, balance); totPaymentInterest(M, totpayment, totinterest, interest); printresults(M, P, r, n, interest, principal, balance, totpayment, totinterest); return 0; }

void intPrinciple(double M, double P, double r, int n, double &interest, double &principal, double & balance) { interest = P * r; principal = M - interest; balance = P - principal;

}

double MPay_formula(double P, double r, int n) { return ( P * (r*pow(1+r, n)) / (pow(1+r,n) - 1)) ; }

void totPaymentInterest(double M, double& totpayment, double& totinterest, double& interest) { totpayment += M; totinterest += M - (M - interest); }

void printresults(double M, double P, double r, int n, double interest, double principal, double balance, double totpayment, double totinterest) { ofstream outputFile("assignment_2output.txt"); cout

void Getinput(double& P, double& r, int& n) { cout > P;

cout > r; cout > n; cout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!