I am working on a project for class. I have it completed thus far and get no other compiler errors aside from error 2064. The exact error I am getting is below. I have been working at this for a few hours now and I am referring to my book, I've looked at other posts and I am still at a loss. Any help is greatly appreciated.
1>C:\Users\tschw\OneDrive\Desktop\Project 07\Project 07\Project 07.cpp(75,73): error C2064: term does not evaluate to a function taking 3 arguments
1>C:\Users\tschw\OneDrive\Desktop\Project 07\Project 07\Project 07.cpp(88,76): error C2064: term does not evaluate to a function taking 2 arguments
1>C:\Users\tschw\OneDrive\Desktop\Project 07\Project 07\Project 07.cpp(107,55): error C2064: term does not evaluate to a function taking 5 arguments
1>C:\Users\tschw\OneDrive\Desktop\Project 07\Project 07\Project 07.cpp(124,48): error C2064: term does not evaluate to a function taking 4 arguments 1>Done building project "Project 07.vcxproj" -- FAILED. ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
#include <iostream>
#include <iomanip>
using namespace std;
double grossPay(int number, double hours, double pay); // hourly function
double grossPay(int number, double salary); // salary function
double grossPay(int company, int project, int number, double hours, double pay); // contract function
double grossPay(int institution, int department, double hours, double pay); // intern function
int main() {
// prompt user for type of employee and give EOF instructions.
cout << "Enter '1' for hourly. Enter '2' for salaried." << endl;
cout << "Enter '3' for contracter. Enter '4' for intern." << endl;
cout << "If result is -1, the input was invalid, please input correct employee hours." << endl;
cout << endl;
cout << "Terminate input by using <ctrl> z on Windows then press enter." << endl;
cout << "Terminate input by using <ctrl> z on UNIX / Linux / Mac OS X then press enter." << endl;
int employeeType{ 0 };
int employeeNumber{ 0 };
double grossPay{ 0 };
double overtimePay{ 0 };
// salaried
double employeeSalary{ 0 };
// hourly
double hoursWorked{ 0 };
double payRate{ 0 };
// contractor
int companyNum{ 0 };
int projectNum{ 0 };
// intern
int schoolCode{ 0 };
int departmentCode{ 0 };
while (cin >> employeeType) {
switch (employeeType) {
case 1:
// HOURLY employee prompts and output
cout << "Enter employee number: " << endl;
cin >> employeeNumber;
cout << "Enter number of hours employee worked: " << endl;
cin >> hoursWorked;
cout << "Enter employees pay rate: " << endl;
cin >> payRate;
cout << setprecision(2) << fixed;
cout << "Gross pay of employee including overtime, is $" << grossPay(employeeNumber, hoursWorked, payRate) << endl;
cout << endl;
break;
case 2:
// SALARIED employee prompts and output
cout << "Enter employee number: " << endl;
cin >> employeeNumber;
cout << "Enter employees salary: " << endl;
cin >> payRate;
cout << setprecision(2) << fixed;
cout << "Gross pay of employee" << employeeNumber << "is $" << grossPay(employeeNumber, payRate) << endl;
cout << endl;
break;
case 3:
// CONTRACT employee prompts and output
cout << "Enter company number: " << endl;
cin >> companyNum;
cout << "Enter project number: " << endl;
cin >> projectNum;
cout << "Enter employee number: " << endl;
cin >> employeeNumber;
cout << "Enter number of hours employee worked: " << endl;
cin >> hoursWorked;
cout << "Enter employees pay rate: " << endl;
cin >> payRate;
cout << setprecision(2) << fixed;
cout << "Gross pay of contractor is $" << grossPay(companyNum, projectNum, employeeNumber, hoursWorked, payRate) << endl;
cout << endl;
break;
case 4:
// INTERN prompts and output
cout << "Enter institution code: " << endl;
cin >> schoolCode;
cout << "Enter department code: " << endl;
cin >> departmentCode;
cout << "Enter number of hours employee worked: " << endl;
cin >> hoursWorked;
cout << "Enter employees pay rate: " << endl;
cin >> payRate;
cout << setprecision(2) << fixed;
cout << "Gross pay of intern $" << grossPay(schoolCode, departmentCode, hoursWorked, payRate) << endl;
cout << endl;
break;
}
cout << "Enter '1' for hourly. Enter '2' for salaried." << endl;
cout << "Enter '3' for contracter. Enter '4' for intern." << endl;
cout << endl;
}
cout << endl;
cout << "Thank you for using this program. " << endl;
}
// hourly function
double grossPay(int number, double hours, double pay) {
double hourlyWeek{ 0 };
while (hours > 0 && hours <= 50.00) {
if (hours > 40.00) {
hourlyWeek = ( ( pay * 40.00) ( hours - 40.00) * (pay *1.50) );
}
else {
hourlyWeek = (hours * pay);
}
}
while (hours > 50.00) {
hourlyWeek = -1;
}
return hourlyWeek;
}
// salary function
double grossPay(int number, double salary) {
double salaryWeek{ 0 };
salaryWeek = (salary * 40);
return salaryWeek;
}
//contractor function
double grossPay(int company, int project, int number, double hours, double pay) {
double contractWeek{ 0 };
while (hours > 0 && hours <= 40.00) {
contractWeek = ((pay * 40.00) (hours - 40.00) * (pay * 1.50));
}
while (hours > 40.00) {
contractWeek = -1;
}
return contractWeek;
}
// intern function
double grossPay(int institution, int department, double hours, double pay) {
double internWeek{ 0 };
while (hours > 0 && hours <= 20.00) {
if (hours > 15.00) {
internWeek = ((pay * 40.00) (hours - 40.00) * (pay * 1.25));
}
else {
internWeek = (hours * pay);
}
}
while (hours > 20.00) {
internWeek = -1;
}
return internWeek;
}
CodePudding user response:
There's a local variable declared as double grossPay{ 0 };
which shadows the function declarations for grossPay()
. In other words, since there's a local definition for grossPay
, the compiler will not use the function definitions. That variable seems to be unused, and removing that line should do the trick.
As a more general tip, it's easier to avoid these kinds of name conflicts with this rule of thumb: Name values with nouns and functions with verbs. In this case, that might involve renaming the functions grossPay()
to getGrossPay()
or calculateGrossPay()
.