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

Please code using C#: Create a class called Plumber that inherits from the Commi

ID: 3816785 • Letter: P

Question

Please code using C#:

Create a class called Plumber that inherits from the Commission Employee class in Figure 11.10 in your Plumber class, Earnings () should calculate the fee earned for a plumbing job. Gross sales represent 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 Commission Employee 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

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote