Mr. Mohlamonyane needs to take out a loan to buy a new car. He wants an application that will allow him to enter the loan amount and the number of years he has to pay off the loan (called the term). The term can be 2 years, 3 years, 4 years, or 5 years only. The application should calculate and display his monthly car payment, using annual (per year) interest rates of 5%, 6%, 7%, 8%, 9% and 10% respectively.
#include <iostream>
using namespace std;
int main()
{
float loan;
int years;
cout << "Please, enter the loan amount: ";
cin >> loan;
cout << "Please, enter the number of years to pay off the loan: ";
cin >> years;
if (years < 2 && years>5)
{
cout << "Incorrect year!";
}
else
{
cout << "Monthly car payment using annual interest rates:\n";
cout << "5%\t6%\t7%\t8%\t9%\t10%\n";
cout << loan / (years * 12) + loan*0.05 / 12 << "\t"
<< loan / (years * 12) + loan*0.06 / 12 << "\t"
<< loan / (years * 12) + loan*0.07 / 12 << "\t"
<< loan / (years * 12) + loan*0.08 / 12 << "\t"
<< loan / (years * 12) + loan*0.09 / 12 << "\t"
<< loan / (years * 12) + loan*0.1 / 12;
}
}
Comments
Leave a comment