67 095
Assignments Done
99,3%
Successfully Done
In November 2018

Answer to Question #39227 in C++ for Ahmed

Question #39227

Write a program that obtains (from the user) the amount, interest rate and number of years of the
loan, then calculates and prints out the monthly payment. Use p, n, r and n for the variable
names when calculating this formula. You may have other variables.
Expert's answer
#include <cstdlib>
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
double a;
double r;
int n; cout << "Input the data, please." << endl;
cout << "------------------------" << endl;
cout << " Amount: ";
cin >> a;
cout << " Interest rate: ";
cin >> r;
cout << " Number of years: ";
cin >> n;
double m = (a + a * r / 100) / (12 * n);
cout.setf(ios::fixed);
cout.precision(2);
cout << endl << "Monthly payment: " << m << endl;
getchar(); getchar();
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions