# Answer to Question #60312 in C++ for anshika

Question #60312

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 for the first year is 7% and an interest rate is 9% and from second year the interest rate increased to 12%. Use constant declarations for these rates.

Use the following formulae to perform the calculations: tax amount = price of car * sales tax rate total cost of car = price of car + tax amount borrowed amount = total cost of car - down payment interest amount = borrowed amount * interest rate loan amount = borrowed amount + interest amount monthly payment = loan amount / number of months of loan Note:

•

Use the following formulae to perform the calculations: tax amount = price of car * sales tax rate total cost of car = price of car + tax amount borrowed amount = total cost of car - down payment interest amount = borrowed amount * interest rate loan amount = borrowed amount + interest amount monthly payment = loan amount / number of months of loan Note:

•

Expert's answer

#include <iostream>

#define TAX_RATE_FIRST_YEAR 0.07

#define INTEREST_RATE_FIRST_YEAR 0.09

#define INTEREST_RATE_SECOND_YEAR 0.12

using namespace std;

int main() {

double price, payment;

int year;

cout << "Input a price of the car: ";

cin >> price;

cout << "Input a down payment: ";

cin >> payment;

cout << "Input number of years: ";

cin >> year;

double borrowed_cost = price * (1 + TAX_RATE_FIRST_YEAR) - payment;

double interest_amount = borrowed_cost * (INTEREST_RATE_FIRST_YEAR + (year - 1)*INTEREST_RATE_SECOND_YEAR);

cout << "Montly payment: " << (borrowed_cost + interest_amount) / (year * 12) << endl;

return 0;

}

#define TAX_RATE_FIRST_YEAR 0.07

#define INTEREST_RATE_FIRST_YEAR 0.09

#define INTEREST_RATE_SECOND_YEAR 0.12

using namespace std;

int main() {

double price, payment;

int year;

cout << "Input a price of the car: ";

cin >> price;

cout << "Input a down payment: ";

cin >> payment;

cout << "Input number of years: ";

cin >> year;

double borrowed_cost = price * (1 + TAX_RATE_FIRST_YEAR) - payment;

double interest_amount = borrowed_cost * (INTEREST_RATE_FIRST_YEAR + (year - 1)*INTEREST_RATE_SECOND_YEAR);

cout << "Montly payment: " << (borrowed_cost + interest_amount) / (year * 12) << endl;

return 0;

}

Need a fast expert's response?

Submit orderand get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

## Comments

## Leave a comment