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

Question: A company pays its employees on a weekly basis. The company has two ty

ID: 3539960 • Letter: Q

Question

Question:

A company pays its employees on a weekly basis. The company has two types of employees:

Salaried employees, who are paid a fixed weekly salary regardless of the number of hours worked;%u037E
Hourly employees, who are paid by the hour and receive overtime pay;%u037E

Create a non-GUI-based Java application that

Calculates weekly pay for an employee. The application should display text that requests the user input the name of the employee, type of employee, and the monthly salary, or hourly rate, if it%u2019s an hourly employee, and hours worked for the week.

For hourly employees, the rate will be doubled if it%u2019s beyond 40 hours/week. The application should then print out the name of the employee and the weekly pay amount. In the printout, display the dollar symbol ($) to the left of the weekly pay amount and format the weekly pay amount to display currency.

Implements a feature that allows the company to:

Reward selected salaried employees by adding 10% to their salaries. Your program should display an asterisk (*) to the upper right of the weekly pay amount, and a note stating bonus added below the table


This program needs to be written using one super class (pay), two subclasses (one for the hourly and one for the salried) and another class that contains main where input and output is done. 4 seperate java files need to be turned in.


Will give full points only to a proper answer with code, otherwise no points will be given. Thank you.

Explanation / Answer

import java.text.*;
import java.util.*;
// save in pay.java
public class pay
{
String name;
public pay(String name)
{
this.name = name;
}
public double calculate_weekly_pay()
{
    return 0.0;
}
}
// END of pay.java

// save in hourly_employee.java

public class hourly_employee extends pay
{
int no_of_hours;
double hourly_pay;
public hourly_employee(String name,int h,double h_p)
{
super(name);
this.no_of_hours = h;
this.hourly_pay = h_p;
}
public double calculate_weekly_pay()
{
if(no_of_hours<40) return hourly_pay*no_of_hours;
else
{
return hourly_pay*no_of_hours + (no_of_hours-40)*2*hourly_pay;
}
}
}

// END OF hourly_employee.java

// save in salried_employee.java

public class salried_employee extends pay
{
double hourly_pay;
public salried_employee(String name,double h_p)
{
super(name);
this.hourly_pay = h_p;
}
public double calculate_weekly_pay()
{
return hourly_pay*40;
}
}

// END OF weekly_employee.java

// save in Main.java

public class Main
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
hourly_employee h_e;
salried_employee w_e;
String name;
System.out.println("Enter the name of the employee ");
name = in.next();
System.out.println("Enter the type of the employee (w for weekly, h for houly) ");
char type = in.next().charAt(0);
if(type=='h')
{
System.out.println("Enter the hourly rate ");
double h_p = in.nextDouble();
System.out.println("Enter no of hours worked ");
int h = in.nextInt();
h_e = new hourly_employee(name,h,h_p);
System.out.println("Weekly pay for " + name + " is given by " + NumberFormat.getCurrencyInstance().format(h_e.calculate_weekly_pay()));
}
else
{
System.out.println("Enter the hourly rate ");
double h_p = in.nextDouble();
w_e = new salried_employee(name,h_p);
System.out.println("Weekly pay for " + name + " is given by " + NumberFormat.getCurrencyInstance().format(w_e.calculate_weekly_pay()));
}
}
}

// END OF Main.java

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