Question

Employee and ProductionWorker Classes DONE IN C# PLEASE Create an Employee class that has properties for...

Employee and ProductionWorker Classes DONE IN C# PLEASE

Create an Employee class that has properties for the following data: • Employee name • Employee number Next, create a class named ProductionWorker that is derived from the Employee class.

The ProductionWorker class should have properties to hold the following data: • Shift number (an integer, such as 1, 2, or 3) • Hourly pay rate The workday is divided into two shifts: day and night.

The Shift property 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.

Create an application that creates an object of the ProductionWorker class and lets the user enter data for each of the object’s properties. Retrieve the object’s properties and display their values.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

using System;
class Employee // base class
{
//variables
private String name;
private int empNum;
  
//properties
public string Name
{

get
{
return name;
}
set
{
name = value;
}
}
  
public int EmpNum
{

get
{
return empNum;
}
set
{
empNum = value;
}
}

//constructor
public Employee(string name,int empNum)
{
this.name = name;
this.empNum = empNum;

}

public string toString()
{
return "\nEmployee Number : "+empNum +" Name : "+name;
}
}
class ProductionWorker : Employee // derived class
{
private int shift;
private double hourlyPayRate;
  
//properties
public int Shift
{
   get
   {
       return shift;
   }
   set
   {
       shift = value;
   }
}
public double HourlyPayRate
{
   get
   {
       return hourlyPayRate;
   }
   set
   {
       hourlyPayRate = value;
   }
}

//passing parameters to base class Employee from derived class ProductionWorker
public ProductionWorker(String name,int empNum,int shift,double hourlyPayRate): base(name,empNum)
{
this.shift = shift;
this.hourlyPayRate = hourlyPayRate;
}


public string toString()
{
return base.toString() + "\nShift : "+shift + " Hourly Pay Rate : $"+hourlyPayRate;
}
}

  
public class Test
{
   public static void Main()
   {
   Console.WriteLine("Enter the name of Employee : ");
string name = Console.ReadLine();
Console.WriteLine("Enter the Employee number : ");
int empNum = Convert.ToInt32(Console.ReadLine());
  
Console.WriteLine("Enter the shift : ");
int shift = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the hourly Pay rate : ");
double hpr = Convert.ToDouble(Console.ReadLine());
  
ProductionWorker pc = new ProductionWorker(name,empNum,shift,hpr);
  
  
Console.WriteLine("Employee Number : "+pc.EmpNum);
Console.WriteLine("Employee Name : "+pc.Name);
Console.WriteLine("Employee Shift : "+pc.Shift);
Console.WriteLine("Employee Hourly Pay rate : $"+pc.HourlyPayRate);
  
  
  
   }
}

Output:

Success #stdin #stdout 0s 131520KB

Enter the name of Employee : James Clark
Enter the Employee number : 6670
Enter the shift : 1
Enter the hourly Pay rate : 50.78
Employee Number : 6670
Employee Name : James Clark
Employee Shift : 1
Employee Hourly Pay rate  : $50.78

Do ask if any doubt. Please upvote.

Add a comment
Know the answer?
Add Answer to:
Employee and ProductionWorker Classes DONE IN C# PLEASE Create an Employee class that has properties for...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • JAVA HELP Design a class named Employee. The class should keep the following information in fields:...

    JAVA HELP Design a class named Employee. The class should keep the following information in fields: Employee name Employee number in the format XXX–L, where each X is a digit within the range 0–9 and the L is a letter within the range A–M. Hire date then, Write one or more constructors and the appropriate accessor and mutator methods for the class. Next, write a class named ProductionWorker that extends the Employee class. The ProductionWorker class should have fields to...

  • C++ Lab 9B Inheritance Class Production Worker Create a project C2010Lab9b; add a source file Lab...

    C++ Lab 9B Inheritance Class Production Worker Create a project C2010Lab9b; add a source file Lab9b.cpp to the project. Copy and paste the code is listed below: 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) // Specification file for the ProductionWorker Class #ifndef PRODUCTION_WORKER_H #define PRODUCTION_WORKER_H #include "Employee.h" #include <string> using namespace std; class ProductionWorker...

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

    WRITE IN C++ ONLY PLEASE. IM USING VISUAL STUDIO CODE.1. Employee and ProductionWorker ClassesDesign a class named Employee. The class should keep the following information in• Employee name• Employee number• Hire dateWrite 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...

  • (PLEASE UPLOAD ALL PARTS TO THE QUESTION) (IE: PSEUDO CODE AND JAVA CODE TOGETHER NOT ONE...

    (PLEASE UPLOAD ALL PARTS TO THE QUESTION) (IE: PSEUDO CODE AND JAVA CODE TOGETHER NOT ONE OR THE OTHER) Design an Employee class that fields for the following pieces of information: 1) Employee name 2) Employee number Next design a class named ProductionWorker that extends the Employee class. The ProductionWorker class should have fields to hold the following information: 1) Shift number (an integer, such as 1, 2, or 3) 2)Hourly pay The workday is divided into two shifts day...

  • (PLEASE UPLOAD ALL PARTS TO THE QUESTION) (IE: PSEUDO CODE AND JAVA CODE TOGETHER NOT ONE...

    (PLEASE UPLOAD ALL PARTS TO THE QUESTION) (IE: PSEUDO CODE AND JAVA CODE TOGETHER NOT ONE OR THE OTHER) Design an Employee class that fields for the following pieces of information: 1) Employee name 2) Employee number Next design a class named ProductionWorker that extends the Employee class. The ProductionWorker class should have fields to hold the following information: 1) Shift number (an integer, such as 1, 2, or 3) 2)Hourly pay The workday is divided into two shifts day...

  • Create the Python code for a program adhering to the following specifications. Write an Employee class...

    Create the Python code for a program adhering to the following specifications. Write an Employee class that keeps data attributes for the following pieces of information: - Employee Name (a string) - Employee Number (a string) Make sure to create all the accessor, mutator, and __str__ methods for the object. Next, write a class named ProductionWorker that is a subclass of the Employee class. The ProductionWorker class should keep data attributes for the following information: - Shift number (an integer,...

  • Use python to create this program. 1) Employee Class Write an Employee class that keeps data...

    Use python to create this program. 1) Employee Class Write an Employee class that keeps data attributes for the following pieces of information: Note: For all classes, the attributes must be hidden Employee Name Employee Number Hire Date Create accessors and mutators Attributes should be hidden. Create a class attribute that determines a standard pay rate adjustment 4% for raises 2) ProductionWorker Class Write a class named ProductionWorker that is a subclass of Employee that holds the following attributes .Shift...

  • Please answer the following question with Java Modify the Employee and ProductionWorker classes provided below so...

    Please answer the following question with Java Modify the Employee and ProductionWorker classes provided below so they throw exceptions when the following errors occur. - The Employee class should throw an exception named InvalidEmployeeNumber when it receives an employee number that is less than 0 or greater than 9999. - The ProductionWorker class should throw an exception named InvalidShift when it receives an invalid shift. - The ProductionWorker class should thrown anexception named InvalidPayRate when it receives a negative number...

  • Design a class named Person and its two derived classes named Student and Employee. MakeFaculty and Staff derived classes of Employee

    In Java(The Person, Student, Employee, Faculty, and Staff classes)Design a class named Person and its two derived classes named Student and Employee. MakeFaculty and Staff derived classes of Employee. A person has a name, address, phone number, and e-mail address. A student has a class status (freshman, sophomore, junior, or senior). An employee has an office, salary, and date hired. Define a class namedMyDate that contains the fields year, month, and day. A faculty member has office hours and a rank....

  • Create a Java file named Ch6Asg.java that contains a public class named Ch6Asg containing a main()...

    Create a Java file named Ch6Asg.java that contains a public class named Ch6Asg containing a main() method. Within the same file, create another class named Employee, and do not declare it public. Create a field for each of the following pieces of information: employee name, employee number, hourly pay rate, and overtime rate. Create accessor and mutator methods for each field. The mutator method for the hourly pay rate should require the value to be greater than zero. If it...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT