Answer to Question #42085 in C++ for Jess

Question #42085
Write a C++ program that asks the user to enter the price of a car (real), the down
payment (real) and the number of years for the loan (integer). Calculate and output
the monthly payment (real) of that car. Assume the sales tax rate is 7% and an
interest rate is 9%. Use constant declarations for these rates.
1
Expert's answer
2014-06-05T14:57:42-0400
//Question #42085, Programming, C++
#include <iostream>
using namespace std;
int main () {
const float salesTaxRate = 7;
const float interestRate = 9;
float price;
float downPayment;
int numberOfYears;
float monthlyPayment = 0;
cout << "Please enter the price of the car :\n";
cin >> price;

cout << "Please enter down payment :\n";
cin >> downPayment;
cout << "Please enter the number of years for the loan :\n";
cin >> numberOfYears;
price += price*(salesTaxRate / 100); //add to the price the tax for the sale
price -= downPayment;// price without downPayment
price += price*(interestRate/100); // add to the price interest Rate
monthlyPayment = price / (numberOfYears*12);
cout << "You will pay " << monthlyPayment << " in a month.\n";
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