Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ My code is below the question as well as my output. Below my code is how it should look. When I compile the code

C++

My code is below the question as well as my output. Below my code is how it should look. When I compile the code and run it I am only able to put in the name and then the program terminates.

  1. Employee and ProductionWorker Classes

Design a class named Employee. The class should keep the following information in

  • Employee name
  • Employee number
  • Hire date

Write one or more constructors and the appropriate accessor and mutator functions for the class.

Next, write a class named ProductionWorker that is derived from the Employee class. The ProductionWorker class should have member variables to hold the following information:

  • Shift (an integer)
  • Hourly pay rate (a double)

The workday is divided into two shifts: day and night. The shift variable will hold an integer value representing the shift that the employee works. The day shift is shift 1, and the night shift is shift 2. Write one or more constructors and the appropriate accessor and mutator functions for the class. Demonstrate the classes by writing a program that uses a ProductionWorker object.

My code:

#include #include #include #include

using namespace std; class Employee { private: string employeeName; int employeeNumber; int hireDate; public: void setemployeeName(string employeeName); void setemployeeNumber(int); void sethireDate(int); string getemployeeName() const; int getemployeeNumber() const; int gethireDate() const; Employee(); }; void Employee::setemployeeName(string employeeName) { employeeName = employeeName; } void Employee::setemployeeNumber(int b) { employeeNumber = b; } void Employee::sethireDate(int d) { hireDate = d; } string Employee::getemployeeName() const { return employeeName; } int Employee::getemployeeNumber() const { return employeeNumber; } int Employee::gethireDate() const { return hireDate; } Employee::Employee() {

} class ProductionWorker :public Employee { private: int Shift; double hourlyPay; public: void setShift(int); void sethourlyPay(double); int getShift() const; double gethourlyPay() const; ProductionWorker(); }; void ProductionWorker::setShift(int s) { Shift = s; } void ProductionWorker::sethourlyPay(double p) { hourlyPay = p; } int ProductionWorker::getShift() const { return Shift; } double ProductionWorker::gethourlyPay() const { return hourlyPay; } ProductionWorker::ProductionWorker() {

} int main() { ProductionWorker info; string name; int num; int date; int shift; double pay; cout > name; cout > num; cout > date; cout > shift; cout > shift; cout > pay; info.setemployeeName(name); info.setemployeeNumber(num); info.sethireDate(date); info.setShift(shift); info.sethourlyPay(pay); cout

My output:

image text in transcribed

It should look like this and let me enter the information:

image text in transcribed

- 0 G C:\Users\chris\source repos\hw1Debug\hw7.exe Name: John Jones Employee number: Hire date: Shift: Shift number: Pay rate: The data you entered for this employee is as follows: Name: Employee Number: 0 Hire Date: -858993460 Shift: -858993460 Shift number: -858993460 Pay Rate: -92559631349317830736831783200707727132248687965119994463780864.00 Press any key to continue ... I CAUsers\davyn\Documents\courses_troy\l_2013\C++\Homework\student_work\Debug week8_sa... Name : John Jones Employee number: 123 Hire date: 1/1/2006 Shift: Night Shift number: 2 Pay rate: 18.00 Press any key to continue

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Semantics Of A Networked World Semantics For Grid Databases First International Ifip Conference Icsnw 2004 Paris France June 2004 Revised Selected Papers Lncs 3226

Authors: Mokrane Bouzeghoub ,Carole Goble ,Vipul Kashyap ,Stefano Spaccapietra

2004 Edition

3540236090, 978-3540236092

More Books

Students also viewed these Databases questions

Question

=+1. How does your message make an emotional appeal?

Answered: 1 week ago

Question

b. Explain how you initially felt about the communication.

Answered: 1 week ago

Question

3. Identify the methods used within each of the three approaches.

Answered: 1 week ago

Question

a. When did your ancestors come to the United States?

Answered: 1 week ago