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.
1
Expert's answer
2017-05-05T09:21:28-0400
#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 the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS