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

Create a program in JAVA to prompt the user for an employee number, hours worked

ID: 3814303 • Letter: C

Question

Create a program in JAVA to prompt the user for an employee number, hours worked in a week. Then the program will compute the gross pay for the employee based on a $10.00 an hour pay scale. Once the gross is computed, the program will compute the cost of deductions. Deduction percentage will be based on amount of the gross pay as seen in table below:

Amount of Gross Pay

Percentage of salary deducted

< $50

1%

Greater than or equal to $50 but less than $200

5%

>=$200

8%

After calculated gross and deduction amount, the program will print (nicely formatted) the employee information including: employee number, hours worked, gross pay, deduction amount and net pay (gross-deduction).

The program MUST include two methods – the first should accept hours worked as a parameter and return gross pay. The second should accept gross pay and return deduction amount (in dollars – not percentage).

The program should also allow for the user to enter as many employees information as desired until an employee number of 0 is entered indicating that the user is done.

Amount of Gross Pay

Percentage of salary deducted

< $50

1%

Greater than or equal to $50 but less than $200

5%

>=$200

8%

Explanation / Answer

EmployeePayTest.java

import java.util.Scanner;


public class EmployeePayTest {

  
   public static void main(String[] args) {
       Scanner scan = new Scanner(System.in);
       System.out.println("Enter the employee no (0 to quit): ");
       int empNo = scan.nextInt();
       int hours = 0;
       if(empNo != 0){
       System.out.println("Enter the number of hours worked: ");
       hours = scan.nextInt();
       }
       while(empNo != 0){
           double grossPay = getGrossPay(hours);
           double deductAmt = getDeductAmount(grossPay);
           System.out.println("Employee Number: "+empNo);
           System.out.println("Hours Worked: "+hours);
           System.out.println("Gross pay: "+grossPay);
           System.out.println("Deducted Amount: "+deductAmt);
           System.out.println("Net pay: "+(grossPay-deductAmt));
           System.out.println("Enter the employee no (0 to quit): ");
           empNo = scan.nextInt();
           if(empNo != 0){
              
           System.out.println("Enter the number of hours worked: ");
           hours = scan.nextInt();
           }
       }
   }
   public static double getGrossPay(int hours) {
       return hours * 10.0;
   }
   public static double getDeductAmount(double grossPay) {
       int percetange;  
       if(grossPay<50){
           percetange = 1;  
           }
       else if(grossPay>=50 && grossPay<200){
           percetange = 5;
       }
       else{
           percetange =8;
       }
       return (grossPay* percetange)/100;
   }

}

Output:

Enter the employee no (0 to quit):
111
Enter the number of hours worked:
5
Employee Number: 111
Hours Worked: 5
Gross pay: 50.0
Deducted Amount: 2.5
Net pay: 47.5
Enter the employee no (0 to quit):
222
Enter the number of hours worked:
2
Employee Number: 222
Hours Worked: 2
Gross pay: 20.0
Deducted Amount: 0.2
Net pay: 19.8
Enter the employee no (0 to quit):
333
Enter the number of hours worked:
25
Employee Number: 333
Hours Worked: 25
Gross pay: 250.0
Deducted Amount: 20.0
Net pay: 230.0
Enter the employee no (0 to quit):
0

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