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

Using BlueJ Program ( http://www.bluej.org/) Conditionals Create a class named P

ID: 3772132 • Letter: U

Question

Using BlueJ Program (http://www.bluej.org/)

Conditionals Create a class named PayrollCal and do the following:

Create a method to calculate an employee’s pay. The method will receive three parameters when executed. The parameters will carry the number of hours, hourly wage and employee status, values M or S, to the method. When the employee’s hours are less than 40, pay is calculated as hoursWorked multiplied by hourlyRate. When the employee works more than 40 hours the regular pay is calculated as above but the hours over 40 earn 1.5 times the regular pay rate. Only salaried employees (empType = S) may earn overtime however. Upon running the method the user will get the payroll amount returned.

Explanation / Answer

import java.util.*;
public class payrollCal
{
   double numOfHrs = 0.0;
   double hourlyWage = 0.0;
   String empStatus = " ";
   public payrollCal(double coNumOfHrs,double coHourlyWage,String coEmpStatus)
   {
       Scanner readdata = new Scanner(System.in);
      System.out.print("Enter Number of Working Hours: ");
      coNumOfHrs = readdata.nextDouble();
      setCoNumOfHrs(coNumOfHrs);
      System.out.print("Enter Hourly Wage: ");
      coHourlyWage = readdata.nextDouble();
      setCoHourlyWage(coHourlyWage);
      System.out.print("Enter Employee Status: ");
      coEmpStatus = readdata.next();
      setCoEmpStatus(coEmpStatus);
      payrollCal();
   }
   public void setCoNumOfHrs(double setNumOfHrs)
   {
   numOfHrs = setNumOfHrs;
   }
   public void setCoHourlyWage(double setHourlyWage)
   {
       hourlyWage = setHourlyWage;
   }
   public void setCoEmpStatus(String setEmpStatus)
   {
       empStatus = setEmpStatus;
   }
   public double getCoNumOfHrs( )
   {
   return numOfHrs;
   }
   public double getCoHourlyWage( )
   {
       return hourlyWage;
   }
   public String getCoEmpStatus( )
   {
       return empStatus;
   }
   public void payrollCal()
   {
   System.out.println();
   double totalSal = 0.0;
   System.out.println("Total Amo" + getCoNumOfHrs() + ".");
   System.out.println("Total Amo" + getCoEmpStatus() + ".");
   if (getCoEmpStatus().equals("M"))
   {
       System.out.println("To is :" + getCoNumOfHrs() + "." + getCoEmpStatus());
       if (getCoNumOfHrs() <= 40)
       {
           System.out.println("To Amount is :" + getCoHourlyWage() + ".");
           totalSal = getCoHourlyWage() * getCoNumOfHrs();
       }
       else if (getCoNumOfHrs() > 40)
       {
           double lcl40 = 40.0;
           totalSal = lcl40 * getCoHourlyWage();
       }
   }
   else if(getCoEmpStatus().equals("S"))
   {
       if (getCoNumOfHrs() <= 40)
           {
               totalSal = getCoHourlyWage() * getCoNumOfHrs();
           }
           else if (getCoNumOfHrs() > 40)
           {
               double lclExtra = getCoNumOfHrs() - 40;
               totalSal = ( 40 * getCoHourlyWage() ) + (1.5 * getCoHourlyWage() * lclExtra);
           }
   }
  
   System.out.println("Total Amount is :" + totalSal + ".");  
   }
   public static void main(String[] args)
   {
   payrollCal pc = new payrollCal(0, 0, null);
   }
}

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