I need help fixing my code. I'm getting the following errors: 107 C:\Dev-Cpp\TicketFineCalculator.cpp no matching function for call to `TicketFineCalculator::getFine(int&)' and note C:\Dev-Cpp\TicketFineCalculator.cpp:20 candidates are: int TicketFineCalculator::getFine(int, int, int, int)
Here is my code:
#include <iostream> //allows program to perform input and ouput
#include <string> //allows string
using namespace std;
class TicketFineCalculator
{
public:
// Constructor
TicketFineCalculator(int processingFee);
// Calculate the total fine given the road zone, speed limit, and the vehicle's actual speed.
// Return the fine as an integer.
int getFine(int speedingType, int speedLimit, int vehicleSpeed, int totalFine)
{
if (speedingType = 1) // Regular Speed zone-- Fine: $5 per mile over speed limit
{
totalFine = (vehicleSpeed - speedLimit)*5;
}
if (speedingType = 2) // Work zone-- Fine: $6 per mile over speed limit, plus $120
{
totalFine = (vehicleSpeed - speedLimit)*6 + 120;
}
if (speedingType = 3) // Residential zone-- Fine: $7 per mile over speed limit, plus $60
{
totalFine = (vehicleSpeed - speedLimit)* 7 + 60;
}
return totalFine;
}
private:
// Speeding ticket processing fee.
int processingFee;
};
int main ()
{
TicketFineCalculator myTicketFineCalculator(100); //where I created the instance of the class !!!!!!!!!!!!!
int processingFee;
int speedingType;
int speedLimit;
int vehicleSpeed;
int totalFine;
int sentinalValue;
cout << "-------------------------------" << endl;
cout << "Speeding Ticket Fine Calculator" << endl;
cout << "-------------------------------" << endl;
cout << "Enter processing fee, in dollars:";
cin >> processingFee;
int ticketNumber = 1;
do
{
cout << "Speeding Ticket #" << ticketNumber << endl;
cout << "Enter the type of speeding offense (1 for regular, 2 for work zone, 3 for residential district):";
cin >> speedingType;
cout << "Enter the speed limit, in miles per hour:";
cin >> speedLimit;
cout << "Enter the vehicle's speed, in miles per hour:";
cin >> vehicleSpeed;
totalFine = myTicketFineCalculator.getFine(totalFine); //This is where i am having issues calling the function
cout << "The total fine is: " << totalFine + processingFee << endl;
// Sentinal value used to stop or continue the program
cout << "Enter 1 to process another speeding ticket or 0 to quit:";
cin >> sentinalValue;
ticketNumber++;//Increases the ticket number if the caluclator runs again
}
while (sentinalValue != 0);
return 0;
}