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

Salary Calculator - Develop a Java application that determines the gross pay for

ID: 3746941 • Letter: S

Question

Salary Calculator - Develop a Java application that determines the gross pay for each of three employees (listed below). The company pays straight time for the first 40 hours worked by each employee and time and a half for all hours worked in excess of 40. You're given a list of the employees, their number of hours worked last week and their hourly rates. Your program should input this information for each employee, then determine and display the employee's gross pay. Use class Scanner to input the data. Employee Name Hours Rate Timothy 46 $12.50 Sarah 52 $11.75 Adrian 41 $22.25

Explanation / Answer

import java.util.Scanner;

class Employee

{

int hours;

double rate;

String name;

Scanner get = new Scanner(System.in);

Employee()

{

System.out.println("Enter Name of the Employee:");

name = get.nextLine();

System.out.println("Enter Rate of the Employee:");

rate = get.nextDouble();

System.out.println("Enter Hours of the Employee:");

hours = get.nextInt();

}

void display()

{

System.out.println("Employee Name: "+name);

System.out.println("Hours: "+hours);

System.out.println("Rate: "+rate);

System.out.println("Gross Salary: "+calculateGrossSalary());

}

Double calculateGrossSalary() {

if(hours <= 40)

return rate*hours;

else

return (rate*40)+(rate/2)*(hours-40);

}

}

public class EmployeeSalaryCalc {

public static void main(String []args){

Employee e1 = new Employee();

e1.display();

Employee e2 = new Employee();

e2.display();

Employee e3 = new Employee();

e3.display();

}

}

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