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

Has to be written in C#. Write a Windows Forms application that calculates and p

ID: 3791207 • Letter: H

Question

Has to be written in C#. Write a Windows Forms application that calculates and prints the take-home pay for a commissioned sales employee. Allow the user to enter values for the name of the employee and the sales amount for the week. Employees receive 7% of the total sales. Federal tax rate is 18%. Retirement contribution is 15%. Social Security tax rate is 9%. Use appropriate constants. Write Input, Display, and Calculate methods. Your final output should display all calculated values,

including the total deductions and all defined constants.

output should look like this:

Employee name Employees total weekly sales: Federal tax (18%): Retirement contribution (15%) Social Security (9%)

Explanation / Answer

EmployeeTester.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//need to using statement
using EmployeeClassLibrary;

namespace EmployeeConsoleApp
{
    class EmployeeTester
    {
        static void Main(string[] args)
        {
            /*
            // testing with user input
           Employee employeeObject = new Employee();
           employeeObject.EmployeeName = AskForEmployeeName();
           employeeObject.EmployeeTotalSales = AskForEmployeeTotalSales();

           Console.Clear();
           Console.WriteLine(employeeObject.ToString());
            */
         
            // testing without user input
           Employee e = new Employee();
           e.EmployeeName = "Sam";
           Console.WriteLine("Employee Name: " + e.EmployeeName);
           e.EmployeeTotalSales = 10000;
           Console.WriteLine("Total Sales: " +
                e.EmployeeTotalSales.ToString("c"));
           Console.WriteLine("Gross Pay (7%): " +
                e.CalculateGrossPay().ToString("c"));
           Console.WriteLine("Federal Tax (18%): " +
                e.CalculateFedTaxPay().ToString("c"));
           Console.WriteLine("Retirement contribution (10%): " +
                e.CalculateRetirementPay().ToString("c"));
           Console.WriteLine("Social Security (6%): " +
                e.CalculateSocialSecurityPay().ToString("c"));
           Console.WriteLine("Total Net Pay: " +
                e.CalculateTakeHomePay().ToString("c"));
          

           Console.ReadLine();

        }

        public static string AskForEmployeeName()
        {
           string inValue;
           Console.Write("Enter Employee Name: ");
           inValue = Console.ReadLine();                                                  
           return inValue;
        }

        public static double AskForEmployeeTotalSales()
        {
           double inValue;
           Console.Write("Enter Total Sales: ");
           inValue = double.Parse(Console.ReadLine());
           return inValue;
        }
    }
}


Employee.cs

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

namespace EmployeeClassLibrary
{
    public class Employee
    {
        private string employeeName;
        private double employeeTotalSales;

        // need to make following public instead of private
        public const double COMMISSION = .07;
        public const double FEDTAXRATE = .18;
        public const double RETIREMENT = .10;
        public const double SOCIAL_SECURITY = .06;

        //constructor
        public Employee()
        {

        }

        //constructor with one name argument
        public Employee(string name)
        {
            employeeName = name;
        }

        //constructor with two arguments
        public Employee(string name, double totalSales)
        {
            employeeName = name;
            employeeTotalSales = totalSales;
        }
      
        //constructor with six arguments
        public Employee(string name, double totalSales, double commission,
           double fedTaxRate, double retirement, double socialSecurity)
        {
           employeeName = name;
           employeeTotalSales = totalSales;
           commission = COMMISSION;
           fedTaxRate = FEDTAXRATE;
           retirement = RETIREMENT;
           socialSecurity = SOCIAL_SECURITY;
        }
      
        //Properties
        public string EmployeeName
        {
           get
           {
              return employeeName;
           }
           set
           {
              employeeName = value;
           }
        }

        public double EmployeeTotalSales
        {
           get
           {
              return employeeTotalSales;
           }
           set
           {
              employeeTotalSales = value;
           }
        }

        public double Commission
        {
           get
           {
              return COMMISSION;
           }
        }

        public double FedTaxRate
        {
           get
           {
              return COMMISSION;
           }
        }

        public double Retirement
        {
           get
           {
              return RETIREMENT;
           }
        }

        public double SocialSecurity
        {
           get
           {
              return SOCIAL_SECURITY;
           }
        }

        public double CalculateGrossPay()
        {
           return employeeTotalSales * Commission;
        }

        public double CalculateTakeHomePay( )
        {
            return CalculateGrossPay() - (
              CalculateGrossPay() * (FEDTAXRATE + RETIREMENT + SOCIAL_SECURITY));
        }

        public double CalculateFedTaxPay()
        {
            return CalculateGrossPay() * FEDTAXRATE;
        }

        public double CalculateRetirementPay()
        {
           return CalculateGrossPay() * RETIREMENT;
        }

        public double CalculateSocialSecurityPay()
        {
            return CalculateGrossPay() * SOCIAL_SECURITY;
        }

        public override string ToString()
        {
           return "Employee Name: " +
               employeeName +
               " Total Sales: " +
               employeeTotalSales.ToString("c") +
               " Gross Pay (7%): " +
               CalculateGrossPay().ToString("c") +
               " Federal Tax (18%): " +
               CalculateFedTaxPay().ToString("c") +
               " Retirement contribution (10%): " +
               CalculateRetirementPay().ToString("c") +
               " Social Security (6%): " +
               CalculateSocialSecurityPay().ToString("c") +
               " Total Net Pay: " +
               CalculateTakeHomePay().ToString ("c");
        }
    }
}


HourlyEmployee.cs

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

namespace EmployeeClassLibrary
{
   public class HourlyEmployee
   {
      //private char employeeType;
      private double hourlyRate;
      private double hoursPerWeek;
      private double grossPay;

      public const double OVERTIME = 40;
      public const double FEDTAXRATE = .18;
      public const double RETIREMENT = .10;
      public const double SOCIAL_SECURITY = .06;

      public HourlyEmployee()
      {

      }

      //Properties
       /*
      public char EmployeeType
      {
          get
          {
              return employeeType;
          }
          set
          {
              if (value == '1' || value == '2')
              {
                  employeeType = value;
              }
              else
              {
                  throw new ArgumentOutOfRangeException("employeeType", value, "Employee types are 1, or 2.");
              }
          }
      }
       */

      //constructor with two arguments
      public HourlyEmployee(double rate, double hours)
      {
          hourlyRate = rate;
          hoursPerWeek = hours;
      }

      public double Hours
      {
         get
         {
            return hoursPerWeek ;
         }
         set
         {
            if (value > 0)
            {
               hoursPerWeek = value;
            }
            else
            {
               throw new ArgumentOutOfRangeException(
                  "hoursPerWeek", value, "Hours clocked can not be 0 or a negative number.");
            }
         }
      }

      public double HourlyRate
      {
         get
         {
            return hourlyRate;
         }
         set
         {
            if (value >= 10)
            {
               hourlyRate = value;
            }
            else
            {
               throw new ArgumentOutOfRangeException(
                  "hourlyRate", value, "Minumum wage is $10.00/hour.");
            }
         }
      }

      public double CalculateHourlyGrossPay()
      {

            if (Hours <= 40)
            {
               grossPay = hoursPerWeek * hourlyRate;
            }
            else
            {
               grossPay = OVERTIME * hourlyRate + ((hoursPerWeek - OVERTIME) * hourlyRate * 1.5);
            }
            return grossPay;
       
      }

      public double CalculateTakeHomePay()
      {
         return CalculateHourlyGrossPay() - (
           CalculateHourlyGrossPay() * (FEDTAXRATE + RETIREMENT + SOCIAL_SECURITY));
      }

      public double CalculateFedTaxPay()
      {
          return CalculateHourlyGrossPay() * FEDTAXRATE;
      }

      public double CalculateRetirementPay()
      {
          return CalculateHourlyGrossPay() * RETIREMENT;
      }

      public double CalculateSocialSecurityPay()
      {
          return CalculateHourlyGrossPay() * SOCIAL_SECURITY;
      }
  
   }
}


SalariedEmployee.cs

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

namespace EmployeeClassLibrary
{
    public class SalariedEmployee
    {
      
        private double salaryTotal;
      

        public const double OVERTIME = 40;
        public const double FEDTAXRATE = .18;
        public const double RETIREMENT = .10;
        public const double SOCIAL_SECURITY = .06;

        //constructor
        public SalariedEmployee()
        {

        }

       /*
        //constructor with one name argument
        public SalariedEmployee(char type)
        {
            employeeType = type;
        }
       */

        //constructor with one argument
        public SalariedEmployee(double salary)
        {
           salaryTotal = salary;
        }
      
      
      
        //Properties
        /*
        public char EmployeeType
        {
           get
           {
              return employeeType;
           }
           set
           {
              if (value == '1'||value == '2')
              {
                employeeType = value ;
              }
              else
              {
                  throw new ArgumentOutOfRangeException("employeeType", value, "Employee types are 1, or 2.");
              }
           }
        }
         */

        public double SalaryTotal
        {
           get
           {
              return salaryTotal;
           }
           set
           {
              salaryTotal = value;
           }
        }
     
        public double FedTaxRate
        {
           get
           {
              return FEDTAXRATE;
           }
        }
      
        public double Retirement
        {
           get
           {
              return RETIREMENT;
           }
        }

        public double SocialSecurity
        {
           get
           {
              return SOCIAL_SECURITY;
           }
        }

        public double CalculateGrossPay()
        {
           return salaryTotal;
        }

        public double CalculateTakeHomePay( )
        {
            return CalculateGrossPay() - (
              CalculateGrossPay() * (FEDTAXRATE + RETIREMENT + SOCIAL_SECURITY));
        }

        public double CalculateFedTaxPay()
        {
            return CalculateGrossPay() * FEDTAXRATE;
        }

        public double CalculateRetirementPay()
        {
           return CalculateGrossPay() * RETIREMENT;
        }

        public double CalculateSocialSecurityPay()
        {
            return CalculateGrossPay() * SOCIAL_SECURITY;
        }

        public override string ToString()
        {
           return "Employee Type: " +
               "" +
               " Total Salary: " +
               salaryTotal.ToString("c") +
               " Gross Pay (7%): " +
               CalculateGrossPay().ToString("c") +
               " Federal Tax (18%): " +
               CalculateFedTaxPay().ToString("c") +
               " Retirement contribution (10%): " +
               CalculateRetirementPay().ToString("c") +
               " Social Security (6%): " +
               CalculateSocialSecurityPay().ToString("c") +
               " Total Net Pay: " +
               CalculateTakeHomePay().ToString ("c");
        }

    }// end of class employee
}

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