Question

In: Computer Science

Develop a Java application that determines the gross pay for each of three employees.

(Salary Calculator) Develop a Java application that determines the gross pay for each of three employees. 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.

Solutions

Expert Solution

Program

import java.util.ArrayList;
import java.util.Scanner;

/*for storing deatils about the employees*/
class EmployeeDetails{
   private String name;
   private double hoursWorked, payRate;
  
   public EmployeeDetails(String name, double hoursWorked, double payRate) {
       this.name = name;
       this.hoursWorked = hoursWorked;
       this.payRate = payRate;
   }
  
   public double calculateGrossPay() {
       double payment = 0;
       //calculating gross pay as per instruction
       if(hoursWorked > 40)
           payment = payment + (hoursWorked * (1.5 * payRate));
       else
           payment = payment + (hoursWorked * payRate);
      
       return payment;
   }

   @Override
   public String toString() {//for showing output
       return "Name=" + name + "\nHours Worked=" + hoursWorked + "\nPay Rate= $" + payRate
               + "\nGross pay= $" + calculateGrossPay();
   }
  
  
}

public class Test {
   public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
      
       int size;
       String name;
       double payRate, hoursWorked;
      
       //for storing details in the arraylist
       ArrayList ar = new ArrayList<>();
      
       System.out.print("Enter the number of Employees: ");
       size = sc.nextInt();
       for(int i=0; i            sc.nextLine();
           System.out.print("Enter name: ");
           name = sc.nextLine();
           System.out.print("Enter hours worked: ");
           hoursWorked = sc.nextDouble();
           System.out.print("Enter pay rate: ");
           payRate = sc.nextDouble();
          
           ar.add(new EmployeeDetails(name, hoursWorked, payRate));
           System.out.println();
       }
      
       //output
       System.out.println("Employee Details and Gross pay");
       System.out.println("--------------------------------");
       for(EmployeeDetails i: ar) {
           System.out.println(i);
           System.out.println("--------------------------------");
       }
       sc.close();
   }
}

Output


Related Solutions

PSc 2-7 Calculate Gross Pay with Commissions Calculate gross pay for each of the following employees....
PSc 2-7 Calculate Gross Pay with Commissions Calculate gross pay for each of the following employees. All are paid an overtime wage rate that is 1.5 times their respective regular wage rates. NOTE: For simplicity, all calculations throughout this exercise, both intermediate and final, should be rounded to two decimal places at each calculation. 1: Dennis McDonald earns both $8.25/hour and a 11% commission on all sales. During the most recent week, he worked 44 hours and made total sales...
(JAVA) Write an application that reads three nonzero values entered by the user and determines and...
(JAVA) Write an application that reads three nonzero values entered by the user and determines and prints whether they could represent the sides of a triangle. Enter three sizes, separated by spaces(decimals values are acceptable): 4.5·5.5·3.5 A triangle could measure 4.50, 5.50, by 3.50.
Develop a Java application which implements an application for a store chain that has three types...
Develop a Java application which implements an application for a store chain that has three types of stores which are Book, Music, and Movie stores. Your application should have an Item abstract class which should be extended by the Book and Multimedia classes. Item class has abstract priceAfterTax method, you need to implement this method in derived classes. Multimedia class is a superclass for Music and Movie classes. Your project should also include the IPromotion interface, which should be implemented...
Develop a C++ program that will determine the gross pay and net pay (after taxes). Each...
Develop a C++ program that will determine the gross pay and net pay (after taxes). Each employee pays a flat tax of 150.00 on the first 1000.00 dollars earned. If the employee earns less than 1000.00 dollars then he/she pays no taxes. Taxes are computed at 15.5% on all earnings over 1000.00 dollars if the number of dependents is 3 or less and 12.5% if the number of dependents are 4 or more. Sample input/outpt dialog Enter # of yours...
Develop a C++ program that will determine the gross pay and netpay (after taxes). Each...
Develop a C++ program that will determine the gross pay and net pay (after taxes). Each employee pays a flat tax of 150.00 on the first 1000.00 dollars earned. If the employee earns less than 1000.00 dollars then he/she pays no taxes. Taxes are computed at 15.5% on all earnings over 1000.00 dollars if the number of dependents is 3 or less and 12.5% if the number of dependents are 4 or more.
Calculate gross pay for each of the following employees of Launchpad Co. The company offers a...
Calculate gross pay for each of the following employees of Launchpad Co. The company offers a regular wage rate of $8.20/hour to all employees. Under an incentive plan in place for all employees, this rate increases for any employee who can meet weekly production goals. The increased rates and corresponding thresholds that must be met are as follows: $9.40/hour for producing at least 2,000 units $10.60/hour for producing at least 2,800 units $11.80/hour for producing at least 3,700 units $13/hour...
Calculate gross pay for each of the following employees. All are paid an overtime wage rate...
Calculate gross pay for each of the following employees. All are paid an overtime wage rate that is 1.5 times their respective regular wage rates. NOTE: For simplicity, all calculations throughout this exercise, both intermediate and final, should be rounded to two decimal places at each calculation. 1:Anita Workman receives tips from customers as a standard component of her weekly pay. She is paid $2.60/hour by her employer and receives $291 in tips during the most recent 44-hour workweek. Gross...
Calculate gross pay for each of the following employees. All are paid an overtime wage rate...
Calculate gross pay for each of the following employees. All are paid an overtime wage rate that is 1.5 times their respective regular wage rates. NOTE: For simplicity, all calculations throughout this exercise, both intermediate and final, should be rounded to two decimal places at each calculation. 1:Walter Pinkman assembles merchandise and is paid $0.12 for each unit assembled. During the most recent week, he worked 44 hours and assembled 5,602 units. Gross Pay = $ 2:Sidney Darling is a...
How to write a java application that reads an integer, then determines and display whether it's...
How to write a java application that reads an integer, then determines and display whether it's odd or even. Use the remainder operator.
Develop a Java application to simulate a game played in an elementary classroom. In this game,...
Develop a Java application to simulate a game played in an elementary classroom. In this game, the teacher places herself in the center of a circle of students surrounding her. She then distributes an even number of pieces of candy to each student. Not all students will necessarily receive the same number of pieces; however, the number of pieces of candy for each student is even and positive. When the teacher blows a whistle, each student takes half of his...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT