Please program in C++ Suppose that you shop for a car. It is always a wise idea
ID: 3716235 • Letter: P
Question
Please program in C++
Suppose that you shop for a car. It is always a wise idea to know how to compute the monthly payments, the cost of financing, etc. Write a program that asks the user to enter the following
1. ask for the sale price: double sale_price
2. compute the sale tax (say NYS is 8.5% of the sale price): double sale_tax
3. ask for dealer fees: some value at most $75 (in NYS): double doc_fee
4. registration and inspection: set it to $85. (in NYS) double reg_fee
5. Add these up: double price
6. Set the down payment: double down_pay
7. Subtract the 6. from 5. to get amount of loan: double loan
8. Ask for the annual rate for the loan: double r; This is a percentage value. It then should be divided by 12; for example, 3.5% become 0.035 / 12 (this is the monthly rate)
9. Ask for the loan duration: int n which is the number of months for the loan to be paid off; for example 36mo, 48, 60mo, etc.
10. Now you can compute the monthly payment double mo_pay as follows:
where the above formula is connected with the compound interest formula from the previous problem.
11. Compute the cost of the loan: finance_cost = n * mo_pay - loan;
12. Compute the total cost of the car: total_cost = down_pay + n * mo_pay
13. Print all the values in a tabulated fashion as if you were to write a contract of sale.
r(1+r) mo - pain = loan * (1+r) - 1Explanation / Answer
#include <iostream>
#include <cmath>
using namespace std;
int main() {
double sale_price,sale_tax,doc_fee,reg_fee,price,loan,down_pay,r,mo_pay,finance_cost,total_cost;
int n;
cout<<"Enter the sale price : ";
cin>>sale_price;
sale_tax = 0.085*sale_price;
cout<<" Enter dealer fees: some value at most $75 (in NYS):";
cin>>doc_fee;
reg_fee = 85;
price = sale_price+sale_tax+reg_fee;
cout<<" Enter the down payment : ";
cin>>down_pay;
loan = price - down_pay;
cout<<" Enter annual rate for the loan: ";
cin>>r;
r = r/1200;//monthly rate
cout<<" Enter the loan duration: ";
cin>>n;
mo_pay = loan *((r*pow((1+r),n))/(pow((1+r),n)-1));
finance_cost = n * mo_pay - loan;
total_cost = down_pay + n * mo_pay;
cout<<" Price loan MonthlyPayment";
cout<<" "<<price<<" "<<loan<<" "<<mo_pay;
return 0;
}
Output:
Enter the sale price :40000
Enter dealer fees: some value at most $75 (in NYS):100
Enter the down payment :2000
Enter annual rate for the loan:10
Enter the loan duration:10
Price loan MonthlyPayment
43485 41485 4341.01
Do ask if any doubt. Please upvote.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.