Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C# windows form application Employee and ProductionWorker Classes Create an Empl

ID: 3855012 • Letter: C

Question

C# windows form application Employee and ProductionWorker Classes 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 let the user enter data for each of the object's properties. Retrieve the object's properties and display their values.

Explanation / Answer

using System;
namespace WagesCalc
{
   class Employee           // //////// base class
   {
      protected int empno;
      protected string empname;

      public void setempno(int eno)
      {
         this.empno = eno;
      }
      public void setempname(string enme)
      {
         this.empname = enme;
      }

      public void getEMPinfo()
      {
         Console.WriteLine(" Employee number is: "+ empno +" name is: "+empname);
      }
   }

   class ProductionWorker: Employee       // ////////// Derived class
   {
        protected string empshft;
        protected float emphrpayamt;

   ProductionWorker(){}
    
   public void setempshft(string shft)
      {
         this.empshft = shft;
      }


   public void setSHFTrate()
      {
   if(empshft=="1")
        emphrpayamt=12.5;
   else if(empshft=="2")
        emphrpayamt=15.5;
   else
       emphrpayamt=10.0;
       }
   
   public void totdisplay()
      {
         Console.WriteLine(getEMPinfo()+" shift mapped is: "+ empshft +" hourly pay rate is : "+emphrpayamt +"$");
      }

   }

   class WagesCalc
   {
      static void Main(string[] args)
      {
         ProductionWorker w1 = new ProductionWorker();   // ////// Object creation
       
         Console.WriteLine("Enter name of employee : "); // ////// Taking Inputs from user
        string name=Console.ReadLine();
        setempname(name);
   Console.WriteLine("Enter ID of employee : ");
        int eid=Convert.ToInt32(Console.Readline());
        w1.setempno(eid);
   Console.WriteLine("Enter the shift of employee worked on: <Make sure there are 2 shifts> type 1 for Morning Shift 2 for Night Shift..... Do not gie any other number for shift to avoid wrong wage calculation : ");
        string shft=Console.ReadLine();
        w1.setempshft(shft);

   int chc;                                 // //// asking for display of details
   do
   {
      Console.WriteLine("Press 1 to display all details 2 to display only basic details or else this will exit : ");
          chc=Convert.ToInt32(Console.Readline());

         }while((chc==1) || (chc==2) );


   Console.WriteLine("Thanks for visit !!");
         Console.ReadKey();
      }
   }
}


::output::
Enter name of employee : Samm
Enter ID of employee : 1234
Enter the shift of employee worked on:
<Make sure there are 2 shifts>
type 1 for Morning Shift 2 for Night Shift..... Do not gie any other number for shift to avoid wrong wage calculation : 1

Press 1 to display all details 2 to display only basic details or else this will exit : 1

Employee number is: 1234 name is: Samm
shift mapped is: 1 hourly pay rate is : 12.5$