Question: Make three modifications to the program. 1. Compare both monthly payments and then display one of the following three messages a. Take the rebate and

Make three modifications to the program.

1. Compare both monthly payments and then display one of the following three messages

a. Take the rebate and finance through the credit union.

b. Don't take the rebate. Finance through the dealer.

c. You can finance through the dealer or the credit union.

2. The user should be able calculate the monthly payments as many times as needed without having to run the program again.

3. Allow the user to enter an interest rate as either a whole number or a decimal number. For example, if the interest rate 5%, the user should be able to enter the rate as either 5 or .05.

#include

#include

#include

using namespace std;

//function prototype

double getPayment(int, double, int);

int main ( )

{

int carPrice = 0;

int rebate = 0;

double creditRate = 0.0;

double dealerRate = 0.0;

int term = 0;

double creditPayment = 0.0;

double dealerPayment = 0.0;

cout << "Car price (after any trade-in): ";

cin >> carPrice;

cout << "Rebate: ";

cin >> rebate;

cout << "Credit union rate: ";

cin >> creditRate;

cout << "Dealer rate: ";

cin >> dealerRate;

cout << "Term in years: ";

cin >> term;

//call function to calculate payments

creditPayment = getPayment (carPrice - rebate, creditRate / 12, term * 12);

dealerPayment = getPayment (carPrice, dealerRate / 12, term * 12);

//display payments

cout << fixed << setprecision(2) << end1;

cout << "Credit union payment: $"

<< creditPayment << end1;

cout << "Dealer payment: $"

<< dealerPayment << end1;

return 0;

} //end of main function

// ****function definitions****

double getPayment (int prin, double monthRate, int months)

{

//calculates and returns a monthly payment

double monthPay = 0.0;

monthPay = prin * monthRate / (1 - pow(monthRate + 1, -months));

return monthPay;

} //end of getPayment Function

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!