I really burnt out from this program and have the following errors , any help would be awesome, thanks.
PS. the dat i'm trying to upload has the following info.
dat:
40.0 10.00
38.5 9.50
16.0 7.50
42.5 8.25
22.5 9.50
40.0 8.00
38.0 8.00
40.0 9.00
44.0 11.75
Errors:
9 IntelliSense: too few arguments in function call c:\Users\Wolfe\Documents\Visual Studio 2013\Projects\Payroll Objects\Payroll Objects\Ch.8_13.cpp 103 37 Payroll Objects
10 IntelliSense: too few arguments in function call c:\Users\Wolfe\Documents\Visual Studio 2013\Projects\Payroll Objects\Payroll Objects\Ch.8_13.cpp 104 41 Payroll Objects
8 IntelliSense: no operator ">>" matches these operands
operand types are: std::ifstream >> Payroll c:\Users\Wolfe\Documents\Visual Studio 2013\Projects\Payroll Objects\Payroll Objects\Ch.8_13.cpp 89 14 Payroll Objects
11 IntelliSense: expression must have class type c:\Users\Wolfe\Documents\Visual Studio 2013\Projects\Payroll Objects\Payroll Objects\Ch.8_13.cpp 105 41 Payroll Objects
6 IntelliSense: expected an expression c:\Users\Wolfe\Documents\Visual Studio 2013\Projects\Payroll Objects\Payroll Objects\Ch.8_13.cpp 87 59 Payroll Objects
7 IntelliSense: expected an expression c:\Users\Wolfe\Documents\Visual Studio 2013\Projects\Payroll Objects\Payroll Objects\Ch.8_13.cpp 87 61 Payroll Objects
Error 3 error C2660: 'Payroll::setPayRate' : function does not take 0 arguments c:\users\wolfe\documents\visual studio 2013\projects\payroll objects\payroll objects\ch.8_13.cpp 107 1 Payroll Objects
Error 4 error C2660: 'Payroll::setHoursWorked' : function does not take 0 arguments c:\users\wolfe\documents\visual studio 2013\projects\payroll objects\payroll objects\ch.8_13.cpp 108 1 Payroll Objects
Error 1 error C2228: left of '.setPayRate' must have class/struct/union c:\users\wolfe\documents\visual studio 2013\projects\payroll objects\payroll objects\ch.8_13.cpp 92 1 Payroll Objects
Error 2 error C2228: left of '.setHoursWorked' must have class/struct/union c:\users\wolfe\documents\visual studio 2013\projects\payroll objects\payroll objects\ch.8_13.cpp 93 1 Payroll Objects
Error 5 error C2228: left of '.getGrossPay' must have class/struct/union c:\users\wolfe\documents\visual studio 2013\projects\payroll objects\payroll objects\ch.8_13.cpp 109 1 Payroll Objects
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
|
#include<iostream>
#include<fstream>
#include<iomanip>
using namespace std;
class Payroll
{
private:
double payRate; // Holds an employee hourly pay rate.
double hoursWorked; // An employee's hours worked.
public:
Payroll() // Empty constructor sets the payRate and hoursWorked to
zero.
{
payRate = 0;
hoursWorked = 0;
}
Payroll(double payR, double hoursW) // Constructor checks for payR and
hoursW to be positive
// and sets payRate and hours worked; sets to zero if negative
values are provided.
{
if (payR < 0)
payR = 0;
if (hoursW < 0)
hoursW = 0;
}
void setPayRate(double payR) // Mutator for payRate; checks for payR
to be positive or sets to zero.
{
payRate = payR;
}
void setHoursWorked(double hoursW) // Mutator for hoursWorked;
checks for positive hoursW or sets to zero.
{
hoursWorked = hoursW;
}
double getPayRate() // Accessor to return payRate.
{
return payRate;
}
double getHoursWorked() // Accessor to return hoursWorked.
{
return hoursWorked;
}
double getGrossPay() // Computes and returns gross pay including
OVERTIME, if any.
{
double regularHours,
overtimeHours,
grossPay;
if (hoursWorked > 40) // Calculations neccessary if a person
works over 40 hours
{
overtimeHours = (hoursWorked - 40);
regularHours = (hoursWorked - overtimeHours);
grossPay = (1.5 * overtimeHours * payRate) +
(regularHours * payRate);
}
return grossPay;
}
};
int main()
{
int count = 0;
const int numEmployee = 7; // Number of employees
const int group = 2; // Number of categories
(setpayRate & set hoursWorked)
Payroll employeeInfo[numEmployee][group]; // Array to hold objects
ifstream inputFile;
inputFile.open("C:\\Users\\Wolfe\\Downloads\\payroll(1).dat");
if (!inputFile)
cout << "There was an error opening the file. Please make sure
it exists." << endl;
else
{
while (count < numEmployee && inputFile >> employeeInfo[][])
{
inputFile >> employeeInfo[count][0] >>
employeeInfo[count][1];
count++;
}
}
inputFile.close();
cout << fixed << showpoint << setprecision(2) << endl;
cout << "Employees' gross pay:" << endl;
for (int index = 0; index < numEmployee; index++)
{
employeeInfo[index][2].setPayRate();
employeeInfo[index][1].setHoursWorked();
cout << "Employee # " << index + 1 <<
employeeInfo.getGrossPay();
}
return 0;
}
|