## vinochick

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

using namespace std;

//function prototype
double calcPayment (double, double, int);

int main()
{
//declare variables
double carPrice = 0.0;
double rebate = 0.0;
double creditRate = 0.0;
double dealerRate = 0.0;
int term = 0;
double creditPayment = 0.0;
double dealerPayment = 0.0;
char another = 'Y';

do
{
//get input items
cout << "Car price: ";
cin >> carPrice;
cout << "Rebate:";
cin >> rebate;
cout << "Credit union rate:  ";
cin >> creditRate;
cout <<"Dealer rate:  ";
cin >>dealerRate;
cout << "Term in years:  ";
cin >> term;

if (creditRate >=1)
creditRate = creditRate / 100;
//end if
if (dealerRate >=1)
dealerRate = dealerRate /100;
//end if

//call function to calculate payments
creditPayment = calcPayment (carPrice - rebate,creditRate / 12, term * 12);
dealerPayment = calcPayment (carPrice, dealerRate / 12, term * 12);

//display payments
cout <<fixed << setprecision (2) << endl;
cout << "Credit union payment :  \$"
<<creditPayment <<endl;
cout << "Dealer payment :  \$"
<<dealerPayment << endl;

cout << endl << "Calculate more payments (y/n): ";
cin >> another;
cout << endl;
}  while (toupper(another) == 'Y');

return 0;
}  //end of main function

//*****function definitions*****
double calcPayment (double 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 calcPayment function``````

## Clinton Portis 211

After briefly looking at ye' code.. I would guess a displayPayment () would probably take place of everything going on between line #47 and #52.

## zortec 11

You should put the displayPayment function around line 47. Take the print statements and wrap them in the function.