Question

In: Computer Science

JAVA Program: You are a developer for a company that wants to create a new payroll...

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:

  • Enter employee’s name
  • Enter employee’s base hourly pay
  • Enter the number of hours worked for the week
  • Error if the hours worked exceeds 168 hours
  • Determine if employee is full time or part time
  • Use the following for tax, retirement, and social security deductions (from gross pay)
    • Federal Tax: 3.5%
    • State Tax: 1.75%
    • Social Security: 5%
    • Health Insurance: $100.00
    • Dental Insurance: $30.00
    • Retirement Deduction: 8%

If the hours worked are less than 40 hours mark the employee as part time and do not deduct the following benefits:

  • Health Insurance
  • Dental Insurance
  • Retirement deduction should be 4%

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:

  • Employee Name
  • Employees Hourly Pay
  • Hours Worked
  • Gross Pay
  • Full time or Part time employee
  • Federal tax paid
  • State tax paid
  • Social Security paid
  • Health Insurance paid
  • Dental Insurance paid
  • Retirement Paid
  • Net Pay (after taxes)

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

Solutions

Expert Solution

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();
                    }

                }

            }
        }
    }
}

Related Solutions

JAVA PROGRAMMING. In this assignment, you are to create a class named Payroll. In the class,...
JAVA PROGRAMMING. In this assignment, you are to create a class named Payroll. In the class, you are to have the following data members: name: String (5 pts) id: String   (5 pts) hours: int   (5 pts) rate: double (5 pts) private members (5 pts) You are to create no-arg and parameterized constructors and the appropriate setters(accessors) and getters (mutators). (20 pts) The class definition should also handle the following exceptions: An employee name should not be empty, otherwise an exception...
where can you create a new payroll schedule?
where can you create a new payroll schedule?
Using Java, The program you will be writing displays a weekly payroll report. A loop in...
Using Java, The program you will be writing displays a weekly payroll report. A loop in the program should ask the user for the employee’s number, employee’s last name, number of hours worked, hourly pay rate, state tax, and federal tax rate. After the data is entered and the user hits the enter key, the program will calculate gross and net pay then displays employee’s payroll information as follows and asks for the next employees’ information. if the user works...
In C Programming Create a payroll program to store and calculate the payroll for a small...
In C Programming Create a payroll program to store and calculate the payroll for a small company as follows: Ask the user for the number of employees and only accept the number if it is between 5 and 40 employees, otherwise prompt the user again and test the input, keep repeating until the user enters an acceptable number. Create an array of floats that is 4 rows and an number of columns equal to the number of employees in the...
Create a new Java project named Program 4 Three Dimensional Shapes. In this project, create a...
Create a new Java project named Program 4 Three Dimensional Shapes. In this project, create a package named threeDimensional and put all 3 of the classes discussed below in this package Include a header comment to EACH OF your files, as indicated in your instructions. Here's a link describing the header. Note that headers are not meant to be in Javadoc format. Note that Javadoc is a huge part of your grade for this assignment. Javadoc requires that every class,...
Create a new Java project named Program 4 Three Dimensional Shapes. In this project, create a...
Create a new Java project named Program 4 Three Dimensional Shapes. In this project, create a package named threeDimensional and put all 3 of the classes discussed below in this package Include a header comment to EACH OF your files, as indicated in your instructions. Here's a link describing the header. Note that headers are not meant to be in Javadoc format. Note that Javadoc is a huge part of your grade for this assignment. Javadoc requires that every class,...
CREATE A NEW Java PROGRAM that demonstrates : 1.1 numeric and 1 string exception 2. Create...
CREATE A NEW Java PROGRAM that demonstrates : 1.1 numeric and 1 string exception 2. Create your own user defined exception, COMMENT it well, and add code so that it is thrown.
Java program In this assignment you are required to create a text parser in Java/C++. Given...
Java program In this assignment you are required to create a text parser in Java/C++. Given a input text file you need to parse it and answer a set of frequency related questions. Technical Requirement of Solution: You are required to do this ab initio (bare-bones from scratch). This means, your solution cannot use any library methods in Java except the ones listed below (or equivalent library functions in C++). String.split() and other String operations can be used wherever required....
Create a new Java program named AllAboutMe (For JAVA we use blue J) Write code to...
Create a new Java program named AllAboutMe (For JAVA we use blue J) Write code to have the program print your name, favorite color, and three hobbies to a new text file called “AllAboutMe” using PrintStream. Submit code.
you will create a program with Java to implement a simplified version of RSA cryptosystems. To...
you will create a program with Java to implement a simplified version of RSA cryptosystems. To complete this project, you may follow the steps listed below (demonstrated in Java code) to guide yourself through the difficulties. Step I Key-gen: distinguish a prime number (20 pts) The generation of RSA's public/private keys depends on finding two large prime numbers, thus our program should be able to tell if a given number is a prime number or not. For simplicity, we define...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT