In: Computer Science
JAVA Program:
You are a developer for a company that wants to create a new payroll system. Write a program that can be used to calculate an employee’s take home pay. Example - rmckanryProgram1. Creating a flow chart or using stump code to outline your program first may help.
Include the following features in the program:
If the hours worked are less than 40 hours mark the employee as part time and do not deduct the following benefits:
Use a loop to enter additional employee’s information until you enter the keyword of “Exit” in for the employee’s name. Exit as an employee name should terminate the program. Use both IF (IF/ELSE) or CASE code to make decisions based on the program requirements.
The output expected is as follows:
Hint: Test your code for errors including logic errors.
Deliverables:
Compress your entire project and upload to Canvas when completed.
Example output:
Enter the employee’s name (Exit will terminate program): Rex
M
Enter hourly pay rate 10.00
Enter hours worked 41
Gross Pay = 410.0
Federal Taxes = 14.350000000000001
State Taxes = 7.175000000000001
Social Security Tax = 20.5
Health Deduction = 100.0
Dental Deduction = 30.0
Retirement Deduction = 32.8
Net Pay = 205.175
import java.util.*; public class rmckanryProgram1 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (true) { System.out.println("Enter employee's Name(Exit will terminate program):"); String name=sc.nextLine(); if(name.equalsIgnoreCase("Exit")){ break; } else{ System.out.println("Enter hourly pay rate "); float hrrate=sc.nextFloat(); System.out.println("Enter hours worked "); int hrsworked=sc.nextInt(); if(hrsworked>168){ System.out.println("Error Hours cannot be more than 168 "); break; } else { double grosspay = hrrate * hrsworked; double fedtax = (grosspay * 3.5) / 100; double statetax = (grosspay * 1.75) / 100; double socialsecurity = (grosspay * 5) / 100; double healthinsurance = 100.00; double dentalinsurance = 30.00; if(hrsworked>=40) { double retirementdeductio = (grosspay * 8) / 100; double netpay = grosspay - fedtax - statetax - socialsecurity - healthinsurance - dentalinsurance - retirementdeductio; System.out.println("Gross Pay = "+(grosspay)); System.out.println("Federal Taxes = "+(fedtax)); System.out.println("State Taxes = "+(statetax)); System.out.println("Social Security Tax = "+(socialsecurity)); System.out.println("Health Deduction = "+(healthinsurance)); System.out.println("Dental Deduction = "+(dentalinsurance)); System.out.println("Retirement Deduction = "+(retirementdeductio)); System.out.printf("Net Pay = %.3f\n",netpay); sc.nextLine(); } else { double retirementdeductio = (grosspay * 4) / 100; double netpay = grosspay - fedtax - statetax - socialsecurity - retirementdeductio; System.out.println("Gross Pay = "+(grosspay)); System.out.println("Federal Taxes = "+(fedtax)); System.out.println("State Taxes = "+(statetax)); System.out.println("Social Security Tax = "+(socialsecurity)); System.out.println("Retirement Deduction = "+(retirementdeductio)); System.out.printf("Net Pay = %.3f\n",netpay); sc.nextLine(); } } } } } }
import java.util.*;
public class rmckanryProgram1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (true) {
System.out.println("Enter employee's Name(Exit will terminate program):");
String name=sc.nextLine();
if(name.equalsIgnoreCase("Exit")){
break;
}
else{
System.out.println("Enter hourly pay rate ");
float hrrate=sc.nextFloat();
System.out.println("Enter hours worked ");
int hrsworked=sc.nextInt();
if(hrsworked>168){
System.out.println("Error Hours cannot be more than 168 ");
break;
}
else {
double grosspay = hrrate * hrsworked;
double fedtax = (grosspay * 3.5) / 100;
double statetax = (grosspay * 1.75) / 100;
double socialsecurity = (grosspay * 5) / 100;
double healthinsurance = 100.00;
double dentalinsurance = 30.00;
if(hrsworked>=40) {
double retirementdeductio = (grosspay * 8) / 100;
double netpay = grosspay - fedtax - statetax - socialsecurity - healthinsurance - dentalinsurance - retirementdeductio;
System.out.println("Gross Pay = "+(grosspay));
System.out.println("Federal Taxes = "+(fedtax));
System.out.println("State Taxes = "+(statetax));
System.out.println("Social Security Tax = "+(socialsecurity));
System.out.println("Health Deduction = "+(healthinsurance));
System.out.println("Dental Deduction = "+(dentalinsurance));
System.out.println("Retirement Deduction = "+(retirementdeductio));
System.out.printf("Net Pay = %.3f\n",netpay);
sc.nextLine();
}
else
{
double retirementdeductio = (grosspay * 4) / 100;
double netpay = grosspay - fedtax - statetax - socialsecurity - retirementdeductio;
System.out.println("Gross Pay = "+(grosspay));
System.out.println("Federal Taxes = "+(fedtax));
System.out.println("State Taxes = "+(statetax));
System.out.println("Social Security Tax = "+(socialsecurity));
System.out.println("Retirement Deduction = "+(retirementdeductio));
System.out.printf("Net Pay = %.3f\n",netpay);
sc.nextLine();
}
}
}
}
}
}