Question

Use Visual Studio for the following: Add an HourlyPlusCommissionEmployee class to the PayrollSystem app by subclassing...

Use Visual Studio for the following:

Add an HourlyPlusCommissionEmployee class to the PayrollSystem app by subclassing an existing class. A HourlyPlusCommissionEmployee is a kind of CommissionEmployee with the following differences and specifications:

HourlyPlusCommissionEmployee earns money based on 2 separate calculations:

  • commissions are calculated by the CommissionEmployee base class
  • hourly pay is calculated exactly the same as the HourlyEmployee class, but this is not inherited, it must be duplicated in the added class
  • BasePlusCommissionEmployee inherits from CommissionEmployee and includes (duplicates) the details of SalariedEmployee. Use this as an example of how to inherit from one class and still include details from another class as you write your class.
  • Hint: the use of the word “Base” in BasePlusCommissionEmployee refers to the “base salary”, not the C# keyword “base” which refers to the base class.
  • IMPORTANT: you are not to make any changes whatsoever to any other source code files included in the project. You are only allowed to add a class file named HourlyPlusCommissionEmployee. This added file will include all your code for the exam. Any deviation from these instructions is incorrect and any changes to any other file will likely break the software.
  • You are provided with a main driver program that includes code which already uses your new class and expects it to be there. All of this code must work correctly with your new added class. The application will not compile and run until you complete your piece. Use the driver program code and the comments for hints at what to do in the new class you add.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

CommisionEmployee

public class CommissionEmployee : Employee
{
private decimal gS;
private decimal cR;
public CommissionEmployee( string fst, string lst, string ssn,decimal sls, decimal rt ) : base( fst, lst, ssn )
{
   SalesOfGross = sls;
   RateOfCommision = rt;
}
public decimal RateOfCommision
{
get
{
   return cR;
}
set
{
   cR = ( value > 0 && value < 1 ) ?
   value : 0;
}
}
public decimal SalesOfGross
{
get

{
   return gS;

}

set

{
   gS = ( value >= 0 ) ? value : 0;

}

}
public override decimal Earnings()
{
   return RateOfCommision * SalesOfGross;
}
public override string ToString()
{
   return string.Format( "{ 0 }: { 1 } { 2 }: { 3 : C } { 4 }: { 5 : F2 }", "commission employee", base.ToString(), "gS", SalesOfGross, "cR", RateOfCommision );
}
}

HourlyEmployee

public class HourlyEmployee : Employee{
private decimal payment;
private decimal time;
public HourlyEmployee( string fst, string lst, string ssn,decimal WagePerHour, decimal TotalWorkedHours ): base( fst, lst, ssn )
{
payment = WagePerHour;
time = TotalWorkedHours;
}
public decimal payment
{
get
{
return payment;
}
set
{
payment = ( value >= 0 ) ? value : 0;
}
}
public decimal time
{
get
{
   return time;
}
set
{
time = ( ( value >= 0 ) && ( value <= 168 ) ) ?
value : 0;
}
}
public override decimal Earnings()
{
if ( time <= 40 )
   return payment * time;
else
   return ( 40 * payment ) + ( ( time - 40 ) * payment * 1.5M );
}
public override string ToString() {
return string.Format("hourly employee: {0} {1}: {2:C}; {3}: {4:F2}", base.ToString(), "WagePerHour", payment, "TotalWorkedHours", time );
}
}

Add a comment
Know the answer?
Add Answer to:
Use Visual Studio for the following: Add an HourlyPlusCommissionEmployee class to the PayrollSystem app by subclassing...
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
  • Add an HourlyPlusCommissionEmployee class to the PayrollSystem app by subclassing an existing class. A HourlyPlusCommissionEmployee is...

    Add an HourlyPlusCommissionEmployee class to the PayrollSystem app by subclassing an existing class. A HourlyPlusCommissionEmployee is a kind of CommissionEmployee with the following differences and specifications: HourlyPlusCommissionEmployee earns money based on 2 separate calculations: commissions are calculated by the CommissionEmployee base class hourly pay is calculated exactly the same as the HourlyEmployee class, but this is not inherited, it must be duplicated in the added class BasePlusCommissionEmployee inherits from CommissionEmployee and includes (duplicates) the details of SalariedEmployee. Use this as...

  • Please write below code in C++ using Visual Studio. Write program that uses a class template...

    Please write below code in C++ using Visual Studio. Write program that uses a class template to create a set of items. The program should: 1. add items to the set (there shouldn't be any duplicates) • Example: if your codes is adding three integers, 10, 5, 10, then your program will add only two values 10 and 5 • Hint: Use vectors and vector functions to store the set of items 2. Get the number of items in the...

  • help please Perform the following steps: a) Using NetBeans, Create a New Java Application Project with...

    help please Perform the following steps: a) Using NetBeans, Create a New Java Application Project with Project Name BasePlusCommission Employee Test with Create Main Class check box selected. Create comments to form a descriptive header that has the course name, your name, the assignment title, and a pledge that you have neither received nor provided help to any person. Assignments submitted without this pledge will not be graded. When you have completed the steps (b) and (c) below, you will...

  • In the processLineOfData, write the code to handle case "H" of the switch statement such that:...

    In the processLineOfData, write the code to handle case "H" of the switch statement such that: An HourlyEmployee object is created using the firstName, lastName, rate, and hours local variables. Notice that rate and hours need to be converted from String to double. You may use parseDouble method of the Double class as follows:               Double.parseDouble(rate) Call the parsePaychecks method in this class passing the HourlyEmployee object created in the previous step and the checks variable. Call the findDepartment method...

  • // Write the compiler used: Visual studio // READ BEFORE YOU START: // You are given...

    // Write the compiler used: Visual studio // READ BEFORE YOU START: // You are given a partially completed program that creates a list of patients, like patients' record. // Each record has this information: patient's name, doctor's name, critical level of patient, room number. // The struct 'patientRecord' holds information of one patient. Critical level is enum type. // An array of structs called 'list' is made to hold the list of patients. // To begin, you should trace...

  • use visual studio, this is the step how to creat the project. creat new project in...

    use visual studio, this is the step how to creat the project. creat new project in the next page make sure to select visual C++ then empty project on the next dialog box. after you create new project click on add new item and then select C++ source file (cpp file) and click add. after you finish, make sure you send me the run file ( result) as well Write a program that calculates and prints the amount of wages...

  • For this assignment, you will use your knowledge of arrays and ArrayLists to write a Java...

    For this assignment, you will use your knowledge of arrays and ArrayLists to write a Java program that will input a file of sentences and output a report showing the tokens and shingles (defined below) for each sentence. Templates are provided below for implementing the program as two separate files: a test driver class containing the main() method, and a sentence utilities class that computes the tokens and shingles, and reports their values. The test driver template already implements accepting...

  • Take the class Person. class Person: """Person class""" def __init__(self, lname, fname, addy=''): self._last_name = lname...

    Take the class Person. class Person: """Person class""" def __init__(self, lname, fname, addy=''): self._last_name = lname self._first_name = fname self._address = addy def display(self): return self._last_name + ", " + self._first_name + ":" + self._address Implement derived class Student In the constructor Add attribute major, default value 'Computer Science' Add attribute gpa, default value '0.0' Add attribute student_id, not optional Consider all private Override method display() Test your code with the following driver: # Driver my_student = Student(900111111, 'Song', 'River')...

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