Write the program logic that will compute the paycheck of an employee. This is a
ID: 441241 • Letter: W
Question
Write the program logic that will compute the paycheck of an employee. This is as much an exercise in designing your logic as much as a programming exercise in the grammar and syntax. Your program's logic will perform a user to perform the following: Enter the employee's LAST Name Enter the employee's FIRST Name Enter the employee's ID Number Enter the employee's Total Hours Worked up to a maximum of 60 hours Enter the employee's Pay Per Hour. The Pay per hour cannot be more than $100.00 per hour. It cannot be less than the minimum wage (i.e. $8.50 per hour). Detect any erroneous pay rate and set it to a default. If less then set that employee to a default. If less than the minimum hourly wage, set to the minimum hourly wage. If greater than the maximum rate then set that employee to the maximum rate. Display an appropriate "error message" telling that data entry clerk what they did. Federal tax rate and State tax rate range from zero to 40%. State and Federal tax rates cannot exceed a combined 80%. Calculations include: Compute the Regular Pay (any hours up to 40 hours) Regular Hours X Pay Per Hour Compute the Overtime Pay if ANY (hours OVER 40 hours) Overtime Hours X Pay Per Hour X 1.25 ("time and a quarter" for overtime) Compute Gross Pay Regular Pay + Overtime Pay (if No overtime then Overtime Pay is zero) Compute Federal Taxes Withheld (assume 20% rate, i.e. 0.2) Gross Pay X federal Tax Rate Compute State Taxes Withheld (assume 5% 20% rate, i.e. 0.05) Gross Pay X State Tax Rate Compute Net Pay (Gross Pay - Federal Taxes Withheld - State Taxes Withheld) Output the employee's LAST Name, FIRST Name, ID Number, Total Hours, Regular Hours, Overtime Hours, if any (if NO overtime hours then don't print it), Federal Taxes Withheld, State Taxes Withheld, Net Pay. Output format, I leave to your imagination.Explanation / Answer
import java.io.*; public class payment { public static void main(String args[]) throws IOException { DataInputStream dis = new DataInputStream(System.in); System.out.println("Enter your last name: "); String last = dis.readLine(); System.out.println("Enter your first name: "); String first = dis.readLine(); System.out.println("Enter your ID: "); String ID = dis.readLine(); System.out.println("Enter your total work hrs: "); Double hr = Double.parseDouble(dis.readLine()); if(hr>60){System.out.println("Total Hours can not be more than 60hrs"); System.out.println("Enter your total work hrs: "); hr = Double.parseDouble(dis.readLine());} System.out.println("Enter pay per hrs rate: "); Double rate = Double.parseDouble(dis.readLine()); if(rate>100){System.out.println("Rate per hr. not correct"); rate = 100.00;} if(rate80)System.out.println("Wrong tax rate enterd"); Double rpay; Double otime=0.0; if(hrRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.