The program should ask the user to input his first name, last name, interest rat
ID: 3675538 • Letter: T
Question
The program should ask the user to input his first name, last name, interest rate, number of years and the monthly payment. The program should add 0.5% to the interest rate if the number of years is larger than 20 years. Once the values arc entered, the program should calculate the future value. After the calculation is done, have the program print in a table format the amount of money if the person deposits 1500, 1750, 2000, 2250 and 2500. At the follow ing rates: 4.5%, 4.75%, 5.0%. 5.25% and 5.5% for a 20 years investment. The program should repeat until the user types in Q for quit. The program should verify the inputs:Explanation / Answer
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
using namespace std;
int main(){
cout << fixed << setprecision(2);
string customerName;
double monthlyPayment, interestRate, futureValue;
int numberOfYears;
while(true){
cout << "Enter the customer name: ";
getline(cin, customerName);
if(customerName.compare("Q") == 0){
return 0;
}
cout << "Enter the monthly payment: ";
cin >> monthlyPayment;
cout << "Enter the number of years: ";
cin >> numberOfYears;
cout << "Enter the interest Rate: ";
cin >> interestRate;
double i = interestRate / 1200;
int n = numberOfYears * 12;
futureValue = ((pow(1 + i, n) - 1) / i) * monthlyPayment;
cout << "Customer name: " << customerName << " ";
cout << "Monthly Payment: " << monthlyPayment << " ";
cout << "Number of years: " << numberOfYears << " ";
cout << "Interest Rate: " << interestRate << "% ";
cout << "Future Value = " << futureValue << " ";
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.