This code will not run. I have gone over this over and over. Do you see a problw
ID: 3534156 • Letter: T
Question
This code will not run. I have gone over this over and over. Do you see a problwm with this code?
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
//function prototype
double getpayment(int, double, int);
int main()
{
//declare variables
int carPrice =0;
int rebate =0;
double creditRate =0;
double dealerRate =0;
int term =0;
double creditPayment =0.0;
double dealerPayment =0.0;
//get input items
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) << endl;
cout << "Credit union Payment: $"
<< creditPayment << endl;
cout << "dealerPayment: $"
<< dealerPayment << endl;
system ("pause");
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