Answer to Question #245662 in Java | JSP | JSF for James

Question #245662

v> Write a Java programme (named EmployeePay.java) that calculates the weekly

pay for each of your employees based on the total number of hours they have

worked in a week using the following guidelines.

All employees are paid a regular hourly rate of some amount. (Determine

that amount in Ghana cedis)

Indicate the number of regular working hours for all employees in a week

Some employees occasionally work overtime and are supposed to be paid for

the hours they have worked overtime. (Determine the overtime hourly rate in

Ghana cedis. Note: Overtime hourly rate should be more than the regular

hourly rate).

Employees can however only do a maximum of 2 overtime hours each day


1
Expert's answer
2021-10-02T10:56:10-0400
package employee;

import java.util.Scanner;
public class Employee {
private String name;
private int id;
public Employee(String n, int i){
    name = n;
    id = i;
}
public String getName(){
    return name;
}
 public int getId(){
     return id;
 }
    public static void main(String[] args) {
       System.out.println("How many employees do want to process their details");
       Scanner input = new Scanner(System.in);
       int number = input.nextInt();
       Payment [] emp = new Payment[number];
       System.out.println("Enter the details for 10 employees");
       for(int i=0; i<number; i++){
           System.out.println("Employee "+(i+1));
           System.out.println("Enter employee id");
           int id = input.nextInt();
           System.out.println("Enter employee name");
           String name = input.next();
           System.out.println("Enter employee salary");
           float sal = input.nextFloat();
           
           emp[i] = new Payment(sal, name, id);
       }
       System.out.println("\nThe employees details are:\n\n");
       for(int i=0; i<number; i++){
           System.out.println("Employee "+(i+1));
           emp[i].display();
       }
    }
}
class Payment extends Employee{
    private float salary;
   
    Payment(float sal, String n, int i){
        super(n,i);
        salary = sal; 
    }
    void display(){
        System.out.printf("Employee Name: \t%s\n Employee ID:\t%d"
                + "\n Employee Salary %f ", getName(),getId(),getSalary());
    }
    public float getSalary(){
        return salary;
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS