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

C# Programming: This is all the info. Create a class called Plumber that inherit

ID: 3813796 • Letter: C

Question

C# Programming: This is all the info.

Create a class called Plumber that inherits from the CommissionEmployee class in Figure 11.10 In your Plumber class, Earnings() should calculate the fee earned for a plumbing job. Gross sales represents the amount charged to a customer and commission rate represents the % that a particular plumber earns.   Earnings is the amount charged * commission rate.

Your class should contain a constructor that inherits from the CommissionEmployee class and initializes the instance variables. The Plumber class should add an instance variable for the name of the customer where the plumbing service occurred.   Create a property for it also.

Create a second class that prompts the user for the information for two plumbers, creates the 2 plumber objects , then displays each plumber.

Explanation / Answer

using System;

class CommissionEmployee
{
    private double commRate;
    private double amountCharged;
  
    public CommissionEmployee(double commRate,double amountCharged)
    {
        this.commRate = commRate;
        this.amountCharged = amountCharged;
    }
    public double CommRate
    {
        set{commRate = value;}
        get{return commRate;}
    }
    public double AmountCharged
    {
        set{amountCharged = value;}
        get{return amountCharged;}
    }
  
}
class Plumber :CommissionEmployee
{
    private string customerName;
  
    //passing arguments to base class constructor
    public Plumber(double commRate,double amountCharged,string customerName):base(amountCharged,commRate)
    {
      
        this.customerName = customerName;
    }
    public double Earnings()
    {
        return CommRate * AmountCharged;
    }
  
    public string CustomerName
    {
        set{customerName = value;}
        get{return customerName;}
    }
    public override string ToString()
    {
        return "Customer Name :"+customerName +" Commision rate : "+CommRate;
    }
}

public class Test
{
   public static void Main()
   {
        Console.WriteLine("Enter commission rate ,amount Charged and Customer name:");
        double crate = Convert.ToDouble(Console.ReadLine());
        double amount = Convert.ToDouble(Console.ReadLine());
        string cname = Console.ReadLine();
      
   Plumber p1 = new Plumber(crate,amount,cname);
   Console.WriteLine(p1.ToString());
   Console.WriteLine("Earnings:"+p1.Earnings());
  
   }
}


   Output:

Enter commission rate ,amount Charged and Customer name:

0.6

456

John Smith

Customer name: John Smith

Earnings : 273.6