Question: C# programing Multi level inheritance-Part 2 Given a string NAME and three integers ID , HR , HW. Create a Class HourlyEmployee with following characteristics

C# programing

Multi level inheritance-Part 2

Given a string NAME and three integers ID, HR, HW. Create a Class HourlyEmployee with following characteristics

Extend an Employee class.

Private member variable hourlyRate and hoursWorked as an integer.

Parameterized Constructor with parameters in the order of NAME, ID, HR (for hourlyRate) and HW (for hoursWorked).

Parameterized Constructor should call a super class constructor with NAME and ID. Also, initialize hourlyRate with HR and hoursWorked with HW.

The public function getGrosspay without any parameter and return gross pay amount of type integer.

Grosspay = (hourlyRate * hoursWorked )

Input Alex 101 100 5

Where,

First line represents NAME.

Second line represents ID.

Third line represents hourly rate HR.

Forth line represents hours worked HW.

Output 101 Alex 500

Where,

The first line represents an ID.

The second line represents a NAME.

The third line represents Gross Pay.

Please fill in the partial code below:

using System; using System.Collections.Generic; using System.Linq;

//write your code here

public class Person { private string name; public Person (string s) { setName (s); }

public void setName (string name) { this.name = name; } public string getName () { return this.name; } }

public class Employee : Person { private int id; public Employee (string name, int id) : base (name) { setId (id); } public void setId (int id) { this.id = id; } public int getId () { return this.id; } }

class DriverMain {

public static void Main () { string Name = Console.ReadLine (); int ID = int.Parse (Console.ReadLine ()); int HR = int.Parse (Console.ReadLine ()); int HW = int.Parse (Console.ReadLine ()); HourlyEmployee hourlyEmployee = new HourlyEmployee (Name, ID, HR, HW); Console.WriteLine (hourlyEmployee.getId ()); Console.WriteLine (hourlyEmployee.getName ()); Console.WriteLine (hourlyEmployee.getGrosspay ()); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!