Question

In: Computer Science

Company ARC Inc. is a medium sized civil engineering firm with 150 employees in offices in...

Company ARC Inc. is a medium sized civil engineering firm with 150 employees in offices in Ontario, Alberta, and British Columbia. The design of the payroll system calculates the hourly, bi-weekly, and monthly compensation wages for temporary, contract, and full-time engineering employees. The company wants to revamp its payroll system with consideration of multiple employee type groups mentioned above. You are assigned to create this payroll system that calculates the correct wages for each employee and report the total wage value before and after taxes. You must consider the following: • Temporary employees: hourly wage only, no benefits, income taxed at 15%. • Contract employees: bi-weekly wage only, no benefits, income taxed at 18%. • Fulltime employees: monthly wage only, benefits deducted at 10%, income taxed at 20%. Create a payroll system using Java with at least two classes: Payroll.java and Employee.java. You can add more classes if you think it is necessary. The application is executed by command line only. (No need for GUI or web application forms.) You must add comments to all the classes and methods. Employee.java technical details: Constructor’s parameters • Employee’s Name, Employee ID, Work Type (T, C, F), Wage Assignment 2 – OOP Payroll Part 1 INFO-6094 – Programming 2 Page: 2 Instant variables • String - Employee Name • int - Employee ID • char - Work Type • double - Wage Methods Use setter and getter methods to manipulate the values inputted. For methods, they should be verbs, mixed case with first letter lowercase, and the first letter of each internal word is capitalized (ie. getEmployeeName(String eName) ). Payroll.java technical details: • You can use a data structure such as an Array to store employee information. • The program should continue to execute unless the optional number value “0” is inputted as an answer. • The system must ask and validate the following for the command line values inputted: Option ‘1’: Which option would you like? ____ What is the employee name? ____ What is the employee ID? ____ What is the employee’s work type? ____ What is the employee’s wage? ____ Employee’s wage after tax: # ********************************************** Then the program will loop back and ask, ‘Which option to choose now?’ It will only exit the loop if input is not 1. Option ‘0’: When the user has inputted 0, the following is displayed: Employee name, employee ID, Work Type, Total Wage before tax, Total Wage after tax 1. William White, 234354, C, $4500.00, $3690.00 2. Christy Carpenter, 045644, F, $5500.00, $3850.00 Etc…. Total employees: # Work types: (#) Temporary, (#) Contract, (#) Full-time Assignment 2 – OOP Payroll Part 1 INFO-6094 – Programming 2 Page: 3 Total wages before tax: # Total wages after tax: # Exit program. If an option value that is NOT ‘0’ or ‘1’ is inputted, then the program exists completely. The user must start again. • To validate errors and report them in the command prompt, consider the following: o the hourly pay cannot exceed 90.00 but can be 0 o the bi-weekly pay cannot be below 1000.00 or more than 3500.00 o the monthly pay cannot be less than 3000.00 o employee name must have at least one space and cannot be less than 5 characters o employee ID must be a positive integer o pay must be a positive value

Solutions

Expert Solution


///////////////// Employee. java //////////////

public class Employee {

    private String employeename;

    private int employeeId;

    private char worktype;

    private double wage;

    /**

     * getters and setters

     */

    Employee(String employeename,int employeeId,char worktype,double wage){

        this.employeeId=employeeId;

        this.employeename=employeename;

        this.worktype=worktype;

        this.wage=wage;

    }

    public String getEmployeename() {

        return employeename;

    }

    public int getEmployeeId() {

        return employeeId;

    }

    public double getWage() {

        return wage;

    }

    public char getWorktype() {

        return worktype;

    }

    public void setEmployeename(String employeename){

        this.employeename = employeename;

    }

    public void setEmployeeId(int employeeId) {

        this.employeeId = employeeId;

    }

    public void setWage(double wage) {

        this.wage = wage;

    }

    public void setWorktype(char worktype) {

        this.worktype = worktype;

    }

}

////////////////////////////// Payroll.java /////////////////

public class Payroll {

    /**

     * creating an employee array of 100 capacity for demo purposes

     */

    Employee[] employee =new Employee[100];

    private int count=0;

    void addEmployee(Employee e){

        employee[count++]=e;

    }

    /**

     * returns no of elements in  employee array

     */

    int count(){

        return count;

    }

    /** Calculates wages of employee according to  workType  and incometax */

    double wageAfterTaxCalulator(Employee employee){

        if(employee.getWorktype()=='T'){

            return employee.getWage()-0.15*employee.getWage();

        }

        else if(employee.getWorktype()=='C'){

            return employee.getWage()-0.18*employee.getWage();

        }

        else{

            return employee.getWage()-0.30*employee.getWage();

        }

    }

    /**

     * validations for input of data

     *

     */

    boolean validatePay(char workType,double amount){

        if(workType =='T'){

            if(amount<=90 && amount >=0){

                return true;

            }

            return false;

        }

        else if(workType =='C'){

            if(amount<=3000 && amount >=1000){

                return true;

            }

            return false;

        }

        else{

            if(amount>=3000){

                return true;

            }

            return false;

        }

    }

    boolean validateName(String name){

        name=name.trim();

        if(name.contains(" ") && name.length()>=5){

            return true;

        }

        else{

            return false;

        }

    }

    boolean validateId(int id){

        if(id>0){

            return true;

        }

        return false;

    }

    boolean validatePay(double id){

        if(id>0){

            return true;

        }

        return false;

    }

}


////////////////////// Main .java (for testing of code) //////////////////

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        /** creating a scanner for input */

        Scanner sc=new Scanner(System.in);

        Payroll payroll =new Payroll();   // creating new payroll object

        while(true){

            System.out.println("Which option Would you like? _____ (0 or 1) ");

            int option = sc.nextInt();

            /** if option is 1 or 0 proceeds or else exits */

            if(option ==0 || option ==1){

                if(option ==1){

                    System.out.println("what is Employee name? ______");

                    String name;

                    sc.nextLine();

                    name=sc.nextLine();

                    while(!payroll.validateName(name)){

                        System.out.println(" Entered name must have a white space in between and atleast 5 chars .... Try again");

                        System.out.println("Enter Empoyee name");

                        name=sc.nextLine();

                    }

                    System.out.println("Enter an option for worktype");

                    System.out.println("1. Contract 2. Temporary 3.Fulltime");

                    option=sc.nextInt();

                    while(option!=1 && option!=2 && option!=3){

                        System.out.println(" Please enter a Valid option");

                        option=sc.nextInt();

                    }

                    char workType;

                    if(option ==1){ workType = 'C';}

                    else if(option ==2){ workType = 'T';}

                    else { workType = 'F';}

                    System.out.println("Enter an Employee id");

                    int employeeId;

                    employeeId=sc.nextInt();

                    while(!payroll.validateId(employeeId)){

                        System.out.println(" Please enter positive value");

                        employeeId=sc.nextInt();

                    }

                    System.out.println("Enter Employee wage");

                    int wage;

                    wage=sc.nextInt();

                    while(!payroll.validatePay(workType, wage)){

                        System.out.println("wage entered is not following rules........");

                        System.out.println("Enter according to following rules");

                        System.out.println("1. Hourly wage cannot be greater than $90");

                        System.out.println("2. Biweekly pay should be between $1000 to $3000");

                        System.out.println("1. Monthly pay cannot be less than $3000");                        

                        System.out.println("Enter Employee wage");

                        wage =sc.nextInt();

                    }

                    

                    payroll.addEmployee(new Employee(name, employeeId, workType, wage));

                    

                }

                else{  //if option is 0 prints all the data in employee array

                    

                    if(payroll.count()==0){

                        System.out.println("No data exists");

                        

                        

                    }

                    else{

                    System.out.println("Employee name,Employee Id ,Work Type, Total Wage before tax, Total Wage after tax ");

                    for(int i=0;i<payroll.count();i++){

                        

                        System.out.println(payroll.employee[i].getEmployeename() + ","+payroll.employee[i].getEmployeeId()+","+payroll.employee[i].getWorktype()+ ",$"+payroll.employee[i].getWage()+",$"+payroll.wageAfterTaxCalulator(payroll.employee[i]) );

                    }

                     }

                     sc.close();

                    System.exit(0);

                }

            }

            else{

                sc.close();

                System.exit(0);

            }

        }

    

    }

}


Related Solutions

LGD Consulting is a medium-sized provider of environmental engineering services. The corporation sponsors a noncontributory
LGD Consulting is a medium-sized provider of environmental engineering services. The corporation sponsors a noncontributory, defined benefit pension plan. Alan Barlow, a new employee and participant in the pension plan, obtained a copy of the 2021 financial statements, partly to obtain additional information about his new employer’s obligation under the plan. In part, the pension disclosure note reads as follows:    In attempting to reconcile amounts reported in the disclosure note with amounts reported in the income statement and balance...
Gentry Inc. is a mid-sized tech firm (200 employees and $300 million in revenue) and has...
Gentry Inc. is a mid-sized tech firm (200 employees and $300 million in revenue) and has been privately held since the firm’s inception ten years ago. The organization’s board of directors is keen on expanding the operations globally to take advantage of a growing market. Based on reports from the research and development team, the organization can increase its profitability metrics by 15 to 25% if it expands the operations to China, Japan, and Germany. Becoming a multinational organization will...
Gentry Inc. is a mid-sized tech firm (200 employees and $300 million in revenue) and has...
Gentry Inc. is a mid-sized tech firm (200 employees and $300 million in revenue) and has been privately held since the firm’s inception ten years ago. The organization’s board of directors is keen on expanding the operations globally to take advantage of a growing market. Based on reports from the research and development team, the organization can increase its profitability metrics by 15 to 25% if it expands the operations to China, Japan, and Germany. Becoming a multinational organization will...
The managing director of SleekMode Enterprises, a medium sized firm, are the operators of a number...
The managing director of SleekMode Enterprises, a medium sized firm, are the operators of a number of theme parks in a number a major cities across the country. The theme parks include facilities such as children’s play grounds, cinema halls, roller-coaster rides, restaurants and boat rides, among other attractions. Yeovil Mootooma, the chief marketing officer, has the task of increasing visitor numbers at the company’s theme parks across the country. The company has experienced consistent declines of about 5% in...
Auto Parts, Inc. is medium-sized company that manufactures auto parts in Buffalo, New York. The company...
Auto Parts, Inc. is medium-sized company that manufactures auto parts in Buffalo, New York. The company currently loses $30,000 per month. The owner of the company is evaluating whether she should shut down the factory. She thinks that the factory should continue to operate until the economic environment improves and buyer for the factory can be identified. The logic of the owner is that her company has already invested millions of dollars in the factory over the years. The monthly...
An engineering firm is expanding its offices in the United States. The firm has selected four...
An engineering firm is expanding its offices in the United States. The firm has selected four prime locations near major metropolitan areas. They want to determine if the average hourly wage is significantly different among the four chosen locations since this would impact overall cost. A survey of 20 wages of similar positions in each of the four locations was taken by random sampling, thus the sample size in each location was 5. The following ANOVA table was created based...
McAdoo & Co. is an engineering firm with offices in several cities in the Carolinas. McAdoo’s...
McAdoo & Co. is an engineering firm with offices in several cities in the Carolinas. McAdoo’s fiscal year-end is December 31, and it prepares financial statements just once a year, at year-end. For bookkeeping purposes, McAdoo has adopted a policy to record payments and collections in advance into asset and liability accounts, respectively. The company’s unadjusted trial balance at December 31, 2020 is shown below. All accounts have normal-side balances. Accounts Payable $   356,210 Accounts Receivable 781,940 Accumulated Depreciation –...
– Problem – Belanger & Associates, PC, is an engineering firm with offices in several cities...
– Problem – Belanger & Associates, PC, is an engineering firm with offices in several cities in the Carolinas. Belanger’s fiscal year-end is December 31, and it prepares financial statements just once a year, at year-end. For bookkeeping purposes, the company has adopted a policy to record payments and collections in advance into asset and liability accounts, respectively. Belanger’s unadjustedtrial balance at December 31, 2018 is shown below. All accounts have normal-side balances. Accounts Payable                                                                     $  602,715 Accounts Receivable                                                                     923,610 Accumulated Depreciation –...
Ajax Inc. is a public company ad a new client of Hawtorne Partners, a medium-sized audit...
Ajax Inc. is a public company ad a new client of Hawtorne Partners, a medium-sized audit firm. Jeffrey Rush is the engagement partner on the audit and has asked the members of the audit team to begin the process of gaining an understanding of the client, in accordance with AS 2110. One audit manager leads the group investigating the industry and economic factors, and another helps Jeffrey consider issues at the entity level. Jeffrey will hold discussions with members of...
1. Lauren Yost & Co., a medium-sized CPA firm, was engaged to audit Stuart Supply Company....
1. Lauren Yost & Co., a medium-sized CPA firm, was engaged to audit Stuart Supply Company. Several staff were involved in the audit, all of whom had attended the firm's in-house training program on effective auditing methods. Throughout the audit, Yost spent most of her time in the field planning the audit, supervising the staff, and reviewing their work. 1(Click the icon to view additional information.) 2 Read the requirements . Requirement a. What defense should Lauren Yost & Co....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT