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

1. Description New Firm, based in San Francisco, needs a program to calculate ho

ID: 3596922 • Letter: 1

Question

1. Description

New Firm, based in San Francisco, needs a program to calculate how much to pay its hourly employees. The US Department of Labor requires that employees get paid time and a half for any hours over 40 that they work in a single week. For example, if an employee works 47 hours, they get 7 hours of overtime, at 1.5 times their base pay. The office of Labor Standards Enforcement announces that minimum wage has increased (in San Francisco) to $14.00 an hour as of July 1, 2017. New Firm requires that an employee not work more than 60 hours in a week.

An employee gets paid (hours worked) × (base pay), for each hour up to 40 hours. For every hour over 40, they get overtime = (base pay) × 1.5.

The base pay must not be less than the minimum wage ($14.00 an hour).

If it is, print an error. If the number of hours is greater than 60, print an error message.

2. To Do

Create a new class called NewFirmSalaryCalculator.

Write a method that takes the base pay and hours worked as parameters, and prints the total pay or an error.

The main method shall call this method for each of these employees and print the results to the console:

Employee Base Salary Hours Worked

Employee1 $14.00, 53 hr

Employee2 $25.00, 23 hr

Employee3 $15.50, 67 hr

Employee4 $13.00, 40 hr

So I am writing a code now, would u tell me what should I add and fix?

public class Newfirmsalarycalculator {

     

      public static void salary(double base, int hours){

      // use if..else statement for defining rules and error messages

      }

      public static void main(String[] args) {

           

            (type of variable) Employee = {"1", "2", "3", "4"};

            (type of variable) basePay = {14.00, 25.00, 15.50, 13.00};

            (type of variable) numberHours = {53, 23, 67, 40};

           

            for ( ) // loop all employees

{

                  System.out.println("The employee's name is " + … );

                 

                  // use salary method to compute employee’s salary

            }

      }

}

Explanation / Answer

//source code

package chegg;

public class SalaryCalculator {

public static void salary(double base, int hours){

if(hours>60)

{

System.out.println("Employee can't be assigned more than 60 hours of work");

return;

}

if(base<14.00)

{

System.out.println("Employee must be paid minimum $14 per hour");

return;

}

double salary;

salary = hours>40?((hours-40)*base*1.5+(40*base)):hours*base;

System.out.println(salary);

}

public static void main(String[] args) {

String empName[] = {"1","2","3","4"};

double empBasePay[]={14.00, 25.00, 15.50, 13.00};

int numberHours[] = {53, 23, 67, 40};

System.out.println("Employee Name Base Salary Hours Worked");

for(int i=0; i<empName.length;i++)

{

System.out.print(empName[i]+" ");

System.out.print(empBasePay[i]+" ");

System.out.print(numberHours[i] + " ");

salary(empBasePay[i],numberHours[i]);

}

}

}

//sample output

Employee Name Base Salary Hours Worked

1 14.0 53 833.0

2 25.0 23 575.0

3 15.5 67 Employee can't be assigned more than 60 hours of work

4 13.0 40 Employee must be paid minimum $14 per hour