Answer to Question #255550 in Algorithms for Israel

Question #255550

Algorithm for a program that calculates the take home pay of an employee. The two employees are salaried and hourly. Allow the user to input employee type. If an employee is salaried, allow the user to input the salary amount. If an employee is hourly, allow the user to input the hourly rate and the number of hours clocked for the week. For hourly employees, overtime is paid for hours over 40 at a rate of 1.5 of the base rate. For all employees’ take-home pay federal tax of 18% is deducted. A retirement contribution of 10% and a social security tax rate of 6% should be deducted. Use appropriate constants. Design an object oriented solution. 


1
Expert's answer
2021-10-23T13:53:10-0400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PayScale
{
    class EmpPayScale
    {
        private const decimal FED_TAX = .18M;
        private const decimal RETIRE_CONTRIB = .10M;
        private const decimal SOC_SEC = .06M;
        private decimal payScaleHourly;
        private decimal payScaleSalary;
        private decimal grossIncome;
        private decimal rate;
        private decimal hours;

        public EmpPayScale()
        {

        }
        
        public EmpPayScale(decimal hrs, decimal payRate, decimal grossInc)
        {
            hours = hrs;
            rate = payRate;
            grossIncome = grossInc;
        }

        public decimal PayScaleHourly
        {
            get
            {
                return payScaleHourly;
            }
        }

        public decimal PayScaleSalary
        {
            get
            {
                return payScaleSalary;
            }
        }

        public void SetPayScale(string payClassIf)
        {
            if (payClassIf == "PT")
            {
                if (hours < 40)
                    payScaleHourly = (rate * hours);
            }
            else if (payClassIf == "OT")
            {
                if (hours > 40)
                    payScaleHourly = (rate * hours) * 1.5M;
            }
            else if (payClassIf == "Salary")
            {
                payScaleSalary = grossIncome - (grossIncome * (FED_TAX + RETIRE_CONTRIB + SOC_SEC));
            }
            else
            {
                Console.WriteLine("Enter correct Employee Pay Schedule: " +
                                  "\n PT" +
                                  "\n OT" +
                                  "\n Salary");
            }
        }

    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS