






employee.h
----------
#include <stdio.h>
#include <iostream>
#include <fstream>
class Employee {
private:
int employeeNum;
std::string name;
std::string address;
std::string phoneNum;
double hrWage, hrWorked;
public:
Employee(int en, std::string n, std::string a, std::string pn, double hw, double hwo);
std::string getName();
void setName(std::string n);
int getENum();
std::string getAdd();
void setAdd(std::string a);
std::string getPhone();
void setPhone(std::string p);
double getWage();
void setWage(double w);
double getHours();
void setHours(double h);
double calcPay(double a, double b);
static Employee read(std::ifstream& in);
void write(std::ofstream& out);
};
employee.cpp
----------
//employee.cpp
#include "employee.h"
#include <iostream>
#include <string>
using namespace std;
Employee::Employee(int en, std::string n, std::string a, std::string pn, double hw, double hwo) {
this->employeeNum = en;
this->name = n;
this->address = a;
this->phoneNum = pn;
this->hrWage = hw;
this->hrWorked = hwo;
}
string Employee::getName() {
return name;
}
void Employee::setName(string n) {
this->name = n;
}
int Employee::getENum() {
return employeeNum;
}
string Employee::getAdd() {
return address;
}
void Employee::setAdd(string a) {
this->address = a;
}
string Employee::getPhone() {
return phoneNum;
}
void Employee::setPhone(string p) {
this->phoneNum = p;
}
double Employee::getWage() {
return hrWage;
}
void Employee::setWage(double w) {
this->hrWage = w;
}
double Employee::getHours() {
return hrWorked;
}
void Employee::setHours(double h) {
this->hrWorked = h;
}
double Employee::calcPay(double a, double b) {
const double x = 40.00;
double gross;
if(b > 40)
{
b -= x;
gross = (a * x) + ((a + (a / 2)) * b);
}
else {
gross = a * b;
}
double net = gross - (gross * .2) - (gross * .075);
return net;
}
Employee Employee::read(ifstream &in){
string name, addr, phone;
double wage, hours;
int id;
in >> id;
if(in.fail())
throw runtime_error("end of file");
in.ignore(); //get rid of newline before using getline()
getline(in, name);
getline(in, addr);
getline(in, phone);
in >> wage >> hours;
if(in.fail())
throw runtime_error("end of file");
return Employee(id, name, addr, phone, wage, hours);
}
void Employee::write(ofstream &out)
{
out << employeeNum << endl;
out << name << endl;
out << address << endl;
out << phoneNum << endl;
out << hrWage << endl;
out << hrWorked << endl;
}
main.cpp
========
#include "employee.h"
#include <iostream>
#include <iomanip>
using namespace std;
void PrintCalc(Employee a) {
cout << "Employee Name: "<< a.getName() << endl;
cout << "Employee Number: " << a.getENum() << endl;
cout << "Address: " << a.getAdd() << endl;
cout << "Phone: " << a.getPhone() << endl;
cout << "....................UVU COMPUTER SCIENCE Dept.................................\n\n";
cout << "Pay to the order of " << a.getName() << ".................................... $" << fixed << setprecision(2) << a.calcPay(a.getWage(), a.getHours()) << endl << endl;
cout << "United Community Credit Union\n";
cout << "..............................................................................\n";
cout << "Hours worked: " << fixed << setprecision(2) << a.getHours() << endl;
cout << "Hourly wage: " << a.getWage() << endl << endl;
}
void createFile()
{
string filename;
Employee joe(37, "Joe Brown", "123 Main St.", "123-6788", 45.00, 10.00);
Employee sam(21, "Sam Jones", "45 East State", "661-9000", 30.00, 12.00);
Employee mary(15, "Mary Smith", "12 High Street", "401-8900", 40.00, 15.00);
cout << "Please enter a file name: ";
cin >> filename;
ofstream out(filename.c_str());
joe.write(out);
sam.write(out);
mary.write(out);
out.close();
cout << "Data file created ... you can now run option 2." << endl;
}
void readFile()
{
string filename;
cout << "Please enter a file name: ";
cin >> filename;
ifstream in(filename.c_str());
if(in.fail())
throw runtime_error("Couldn't open file for input");
else
{
for(int i = 0; i < 3; i++)
{
Employee e = Employee::read(in);
PrintCalc(e);
}
in.close();
}
}
int main(int argc, const char * argv[]) {
int choice = 0;
cout << "This program has two options: " << endl;
cout << "1 - Create a data file, or" << endl;
cout << "2 - Read data from a file and print paychecks." << endl;
cout << "Please enter (1) to create a file or (2) to print checks: " ;
cin >> choice;
try {
if(choice == 1)
createFile();
else if(choice == 2)
readFile();
else
cout << "Invalid choice!" << endl;
} catch (runtime_error e) {
cout << e.what() << endl;
}
return 0;
}
It keep showing these errors and I need help correcting the code above
1: Constructor and Getters 0/5 Tests the parameterized constrictor and "Getter functions Compilation failed main.cpp: In function 'bool testPassed (std::ofstream&) main.cpp: 70:10: error: class Employee'has no member named 'getEmploye if (emp.getEmployeeNumber )!-123) main.cpp:82:10: error: 'class Employee' has no member named 'getAddr' if (emp.getAddr-"Cohasset, MA") Compilation failed main.cpp:94:10: error: class Employee' has no member named 'getHourlyW if (emp.getHourlyWage ) 1000000.00) main.cpp:100:10: error 'class Employee' has no member named 'getHoursW if (emp.getHoursWorked)12.0)
2: Setters 0/5 Tests all Setters of Employee class Compilation failed main.cpp: In function 'bool testPassed (std::ofstream&) main.cpp: 71:6: error: class Employee has no member named 'setAddr' d emp.setAddr ("Braintree, MA" main.cpp: 73:6: error: class Employee has no member named 'setHourlyWa emp.setHourlyWage (0.99); main n.cpp: emp.setHoursWorked (5000.0) :74:6: error: class Employee' has no member named setHoursWorl Compilation failed main.cpp: 83:10: error: 'class Employee' has no member named 'getAddr if (emp.getAddr - "Braintree, MA") main.cpp: 95:10: error:'class Employee' has no member named getHourlyW if (emp.getHourlyWage() 0.99) 101:10: error class Employee' has no member named 'getHoursWo if (emp.getHoursWorked) -5000.0)
3: calcPay 075 Test calcPay for both regular and overtime hours Compilation failed main.cpp: In function 'bool testPassed (std::ofstream&) main.cpp: 71:18: error: no matching function for call to 'Employee::calcl if (emp.calcPay)!8700.0) In file included from main.cpp:2:0 employee.h:26:8: note: candidate: double Employee::calcPay (double, doub double calcPay (double a, double b) ; emplovee.h:26:8: note:candidate expects 2 arguments, 0 provided error class Employee' has no member named 'setHoursWorl Compilation failed ain.cpp: 78:6: emp.setHoursWorked (43.5); main.cpp: 79:18: error: no matching function for call to 'Employee::calcl if (emp.calcPay)!32806.25) In file included from main.cpp:2:0 employee.h:26:8: note: candidate: double Employee::calcPay (double, doub double calcPay (double a, double b) ; emplovee.h:26:8: note:candidate expects 2 arguments, 0 provided
4: read0 and write0 0/10 Tests the write0 and static read functions Compilation failed main.cpp: In function 'bool testPassed (std::ofstream&) : 82:10: error: 'class Employee' has no member named 'getEmploye in.cpp if (emp.getEmployeeNumber (123) main.cpp: 94:10: error: 'class Employee' has no member named 'getAddr if (emp.getAddr-"Cohasset MA") Compilation failed 106:10: error class Employee' has no member named 'getHourly if (emp.getHourlyWage()1000.00) :112:10: error class Employee' has no member named 'getHoursWo if (emp.getHoursWorked) !- 12.0)
This program has two options: 1 - Create a data file, or 2 Read data from a file and print paychecks. Please enter (1) to create a file or (2) to print checks: Please enter ployee Number: Address: 123 Main St UVU COMPUTER SCIENCE Dept Pay to the order of Joe Brown. . . . . .. . . . . . . . _ . . . . . . .. . . . . . . . . . $326 United Community Credit Union Hours worked: 10.00 Hourly wage: 45.00 Employee Name:Sam Jones Employee Number: 21 Address: 45 East State Phone: 661-9000 Pay to the order of Sam Jones....... . . . . . . . . . . . . . . . . . . . . .. . . . . . . . $261.0 United Community Credit Union Hours worked: 12.00 Hourly wage: 30.00
United Community Credit Union Hours worked: 12.00 Hourly wage: 30.00 Employee Name: Mary Smith Employee Number: 1 Address: 12 High Street Phone: 401-8900 Pay to the order of Mary Smith. United Community Credit Union Hours worked: 15.00 $435 . . . .. .. .. Hourly wage: 40.00
This program has two options: 1 - Create a data file, or 2 -Read data from a file and print paychecks Please enter (1) to create a file or (2) to print checks: Please enter a file name Pay to the order of Joe Brown....... . . . . .. . . . . . . . . . . . . . . . . . . . .. . $344 United Community Credit Union Hours worked: 45.00 Hourly wage: 10.00 Expected output Pay to the order of Sam Jones . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . $261.0 United Community Credit Union