1 answer

Employee.h ---------- #include <stdio.h> #include <iostream> #include <fstream> class Employee { private: int employeeNum; std::string name;...

Question:

1: Constructor and Getters 0/5 Tests the parameterized constrictor and Getter functions Compilation failed main.cpp: In func2: Setters 0/5 Tests all Setters of Employee class Compilation failed main.cpp: In function bool testPassed (std::ofstream&)3: calcPay 075 Test calcPay for both regular and overtime hours Compilation failed main.cpp: In function bool testPassed (st4: read0 and write0 0/10 Tests the write0 and static read functions Compilation failed main.cpp: In function bool testPassedThis program has two options: 1 - Create a data file, or 2 Read data from a file and print paychecks. Please enter (1) to creUnited Community Credit Union Hours worked: 12.00 Hourly wage: 30.00 Employee Name: Mary Smith Employee Number: 1 Address: 12This program has two options: 1 - Create a data file, or 2 -Read data from a file and print paychecks Please enter (1) to cre

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

Answers

Hello,

The program doesn't have any error that you specified. Only error which I got was as follows in the main.cpp
error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)
The error is corrected by including the header file #include <string> in main.cpp and I was able to execute and see the output given in screenshots.

Apart from these, there are not error found. But anyway I have identified the cause for the error based on your screenshots. If you still facing the issue, implement the below solutions:

Constructor and Getters

emp is instance of Class Employee and this class doesn't have methods getEmployeeNumber(), getAddr(), getHourlyWage() and getHoursWorked()

Solution: Replace the following methods with below given methods:

  • getEmployeeNumber() with getENum()
  • getAddr() with getAdd()
  • getHourlyWage() with getWage()
  • getHoursWorked() with getHours()

Setters

emp is instance of Class Employee and this class doesn't have methods setAddr(), setHourlyWage() and setHoursWorked()

Solution: Replace the following methods with below given methods

  • setAddr("Braintree, MA") with setAdd("Braintree, MA")
  • setHourlyWage(0.99) with setWage(0.99)
  • setHoursWorked(5000.0) with setHours(5000.0)

calcPay

  • calcPay() takes two aurgments both of type double. But as per the error message, no parameters are passed to this method
    Solution: Pass two parameters of type double to method calcPay().

    Example calcPay(10.0, 20.0)

  • emp is instance of Class Employee and this class doesn't have method setHoursWorked()
    Solution: Replace setHoursWorked(43.5) with setHours(43.5)

read() and write()

emp is instance of Class Employee and this class doesn't have methods getEmployeeNumber(), getAddr(), getHourlyWage(), getHoursWorked()

Solution: Replace the following methods with below given methods

  • getEmployeeNumber() with getENum()
  • getAddr() with getAdd()
  • getHourlyWage() with getWage()
  • getHoursWorked() with getHours()

Feel free to ask further doubts. Always here to clarify

.

Similar Solved Questions

1 answer
A Moving to the next question prevents changes to this answer. Question 32 The nurse is...
A Moving to the next question prevents changes to this answer. Question 32 The nurse is preparing to complete a musculoskeletal examination on a client. Which two assessment techniques would the nurse plan to use during this exam? O Inspection and percussion Percussion and palpation O Auscultation a...
1 answer
**JUST NEED HELP WITH IV** capacitor is charged to its max value, so that and ....
**JUST NEED HELP WITH IV** capacitor is charged to its max value, so that and . At t = 0, the voltage source is disconnected from the circuit. i. Write an expression for the charge on the capacitor. Do this symbolically; do NOT plug in the values from parts (a) and (b). ii. Find an expression fo...
1 answer
(2) Schedules Complete the sales and merchandise purchase plans with supporting schedules: a) A sales plan...
(2) Schedules Complete the sales and merchandise purchase plans with supporting schedules: a) A sales plan by month and in total, including a schedule of projected cash collections from sales and accounts receivable, by month and in total (2 schedules). b) An inventory purchases plan in units and in...
1 answer
F LOpoint For the circuit shown in Figure 3 3. 1. Draw the DC equivalent circuit...
F LOpoint For the circuit shown in Figure 3 3. 1. Draw the DC equivalent circuit by opening caps and shorting inductors 2. Analyze the DC equivalent circuit as we have in previous labs (assume a region, analyze and check assumptions). Check your DC operating point using LT Spice. 3. Calculate the sm...
1 answer
Using the Critical Thinking Process, identify 5 disk scheduling options, and 5 disk scheduling criteria. Weigh...
Using the Critical Thinking Process, identify 5 disk scheduling options, and 5 disk scheduling criteria. Weigh the options against the criteria and select the best disk scheduling option for: Identify and select a process-to-process communication technique that best both upward and downward scalabil...
1 answer
A psychologist is interested in knowing whether adults who were bullied as children differ from the...
A psychologist is interested in knowing whether adults who were bullied as children differ from the general population in terms of their empathy for others. On a questionnaire designed to measure empathy, the mean score for the general population is 30.6. Random sampling of 25 scores obtained from i...
1 answer
2. (30 pts) Consider the system of Figure 1 (m-2 kg, k 50 N/m, 0-30°). a) Obtain the equation of motion. b) Compute the initial conditions such that the system oscillates at only one frequency wh...
2. (30 pts) Consider the system of Figure 1 (m-2 kg, k 50 N/m, 0-30°). a) Obtain the equation of motion. b) Compute the initial conditions such that the system oscillates at only one frequency when Fa)-2sin10 c) Calculate the response of the system for F)-2sin10/, xo-0,-10 m/s. d) Calculate the ...
1 answer
Table 3-25 Assume that Maya and Miguel can switch between producing mixers and producing toasters at...
Table 3-25 Assume that Maya and Miguel can switch between producing mixers and producing toasters at a constant rate. Hours Needed to Make 1 mixer toaster Amount Produced in 40 Hours mixers toasters Maya Miguel uel 20 Refer to Table 3-25. Maya has an absolute advantage in the production of...
1 answer
What is the electric field at a point when the force on a 1.25 μC charge placed at that point is F⃗ =(3.0i^−3.9j^)×10−3N? (E⃗ =αi^+βj^N/C) A) α = B) β =
What is the electric field at a point when the force on a 1.25 μC charge placed at that point is F⃗ =(3.0i^−3.9j^)×10−3N? (E⃗ =αi^+βj^N/C) A) α = B) β =...
1 answer
Crasper & Bros, Inc. manufactures phone cases for both Androids and iPhones. Last year, Crasper manufactured 34,060...
Crasper & Bros, Inc. manufactures phone cases for both Androids and iPhones. Last year, Crasper manufactured 34,060 units and sold 28,600 phone cases (units). They have reported the following Production costs for the year: Direct materials $ 255,450 Direct labor $ 173,706 Variable man...
1 answer
Please help :) Problem 1: Complete separately Dr. Rocklino a) Write a program in which the...
Please help :) Problem 1: Complete separately Dr. Rocklino a) Write a program in which the main method creates two arrays, each with 10 int slots. main initializes the first array to randomly generated integers. It then calls a method named copy, passing it the two arrays. Your copy method copies th...
1 answer
Q3d d) One mole of an ideal gas with Cu.m 3/2R is heated reversibly along a...
Q3d d) One mole of an ideal gas with Cu.m 3/2R is heated reversibly along a path such that V = Aexp[bT], where A = 1.2257 liters and b-0010 K-1. How does the pressure vary with T for this system? Obtain the molar heat capacity of the gas as a function of T for heating along the given path. Finally, ...
1 answer
E9-14 Computing and Interpreting the Fixed Asset Turnover Ratio from a Financial Analysts Pe [LO 9-7)...
E9-14 Computing and Interpreting the Fixed Asset Turnover Ratio from a Financial Analysts Pe [LO 9-7) The following data were included in a recent Papayo Inc. annual report (In millions) 2013 $79,225 Net revenue Net property, plant, and equipment 2014 $131,559 9,00 2015 $183,500 15,590 2016 $191,920...
1 answer
Solve the system of equations using matrices. Use the Gaussian elimination method with back-substitution. 4x +...
Solve the system of equations using matrices. Use the Gaussian elimination method with back-substitution. 4x + 4y + 8z = 16 4x + 3y + 62 = 12 4x + 8y + 20z = 28 The solution set is {000)}. (Simplify your answers.)...
1 answer
You thought you were done but your instructor realized someone had left another unknown compound on...
You thought you were done but your instructor realized someone had left another unknown compound on the counter. Your instructor asked you to identify this compound as well so that it can be disposed of properly. You decide to take an IR but find this time it’s completely booked by research st...