Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

19. In this exercise, you will modify the car payment program from Lab 9-2. If n

ID: 3601714 • Letter: 1

Question

19. In this exercise, you will modify the car payment program from Lab 9-2. If necessary create a new project named Intermediate19 Project, and save it in the Cpp8 Chap09 folder. Copy the instructions from the Lab9-2.cpp file into a source file named Intermediate19.cpp. (Alternatively, you can enter the instructions from Figure 9-34 into the Intermediate19.cpp file.) Change the filename in the first comment. Make the modifications listed in Figure 9-39. Test the program appropriately. Before calculating a monthly payment, verify that the denominator in the periodic payment formula is not the number 0. If it is 0, the function should return the number -1 (the negative number 1). 1. 2. In addition to displaying the monthly payments, the program should also display the following two amounts: The total amount the user will pay for the car if the loan is financed through the credit union. The total amount the user will pay for the car if the loan is financed through the car dealer. a. b. Figure 9-39

Explanation / Answer

without creating the new function i just modified the current program and added a new variable months (user input) and calculate the values apart from that if user input o for months value then it return -1 else calculate the values as previous.

#include <iostream>
#include<cmath>
#include<iomanip>

double getPayment(int,double,int);


using namespace std;

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;
int months=0;

cout<<"Car price (after any trade-in):";
cin>>carPrice;
cout<<"Rebate";
cin>>rebate;
cout<<"Credit Union Rate: ";
cin>>creditRate;
cout<<"Daeler Rate:";
cin>>dealerRate;
cout<<"Term in months:";
cin>>term;
cout<<"enter months for terms:";
cin>>months;

if(months==0)
{

return -1;

}

else
{
creditPayment=getPayment((carPrice-rebate),creditRate/months,term*months);
dealerPayment=getPayment(carPrice,dealerRate/months,term*months);


cout<<fixed<<setprecision(2)<<endl;
cout<<"Credit union payment:$" <<creditPayment<<endl;

cout<<"Dealer payment:$" <<dealerPayment<<endl;
}

return 0;
}


double getPayment(int price ,double creditrate,int term)

{
return price+creditrate+term;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote