For a function protoype header can one be double while the other one is void? I'm trying to make the void displayPayment function work, but am a little lost. Should I turn the carPrice, Rebate, ect.. into void functions in the prototype, or can they work without doing that? Thanks for your time, Michelle
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
//function prototype
double calcPayment (double, double, int);
void displayPayment (double, double&);
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;
//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;
//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;
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;
}
void displayPayment (double monthPay)
{
cout << "Monthly Payment: "<< monthPay << endl;
}
//end of calcPayment function