C# program Modify the payroll application. If the object currently being process
ID: 3748279 • Letter: C
Question
C# program
Modify the payroll application. If the object currently being processed is a BasePlusCommissionEmployee, the application should increase the BasePlusCommissionEmployee’s base salary by 10%.
Complete the following steps to create the new application:
a) Modify classes HourlyEmployee and CommissionEmployee to place them in the IPayable hierarchy as derived classes of the version of Employee that implements IPayable. [Hint: Change the name of method Earnings to GetPaymentAmount in each derived class.]
b) Modify class BasePlusCommissionEmployee such that it extends the version of class CommissionEmployee created in Part a.
c) Modify PayableInterfaceTest to polymorphically process three salariedEmployee, two HourlyEmployee, one CommissionEmployee and two Base- PlusCommissionEmployee.
d) Create a menu that allows a user to select one of the following options to display a string representation of each IPayable objects.
Sort last name in descending order using IComparable
Sort pay amount in ascending order using IComparer
Sort by social security number in descending order using a selection sort and delegate
Sorting last name in ascending order and pay amount in descending order by using LINQ
Use the following data to test your program:
IPayable[] payableObjects = new IPayable[ 8 ];
payableObjects[ 0 ] = new SalariedEmployee( "John", "Smith", "111-11-1111", 700M );
payableObjects[1] = new SalariedEmployee("Antonio", "Smith", "555-55-5555", 800M);
payableObjects[2] = new SalariedEmployee("Victor", "Smith", "444-44-4444", 600M);
payableObjects[ 3 ] = new HourlyEmployee( "Karen", "Price", "222-22-2222", 16.75M, 40M );
payableObjects[4] = new HourlyEmployee("Ruben", "Zamora", "666-66-6666", 20.00M, 40M);
payableObjects[ 5 ] = new CommissionEmployee( "Sue", "Jones", "333-33-3333", 10000M, .06M );
payableObjects[ 6 ] = new BasePlusCommissionEmployee( "Bob", "Lewis", "777-77-7777", 5000M, .04M, 300M );
payableObjects[7] = new BasePlusCommissionEmployee("Lee","Duarte", "888-88-888", 5000M, .04M, 300M);
Explanation / Answer
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string name;
int employeeNumber;
double hours;
const double hourlyWage = 7.5;
double gross;
double tax;
double insurance;
double deduction;
private void btnCompute_Click(object sender, EventArgs e)
{
if (txtName.Text == "")
{
MessageB.Text = "...";
}
else if (txtPNumber.Text.Length <= 8)
{
MessageB.Text = "...";
}
else if (txtHoursWork.Text == "")
{
MessageB.Text = "...";
}
else if (btnCompute.Text == "Compute")
{
name = txtName.Text;
employeeNumber = Convert.ToInt32(txtPNumber);
hours = Convert.ToDouble(txtHoursWork.Text);
gross = hours * hourlyWage;
txtGrossPay.Text = "£" + Convert.ToString(gross);
tax = gross / 100 * 20;
txtIncomeTax = "£" + Convert.ToString(tax);
insurance = gross / 100 * 7;
txtNI = "£" + Convert.ToString(insurance);
deduction = tax + insurance;
txtTotalDeduction = "£" + Convert.ToString(deduction);
}
else
{
txtName.Text = "";
txtPNumber.Text = "";
txtHoursWork.Text = "";
txtGrossPay.Text = "";
txtIncomeTax.Text = "";
txtNI.Text = "";
txtTotalDeduction.Text = "";
btnCompute.Text = "Compute";
}
}
private void button1_Click(object sender, EventArgs e)
{
Close();
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.