Question

In: Computer Science

The human resources department for your company needs a program that will determine how much to...

The human resources department for your company needs a program that will determine how much to deduct from an employee’s paycheck to cover healthcare costs. Health care deductions are based on several factors. All employees are charged at flat rate of $150 to be enrolled in the company healthcare system. If they are married there is an additional charge of $75 to cover their spouse/partner. If they have children, the cost is $50 per child. In addition, all employees are given a 10% deduction in the total cost if they have declared to be a “non-smoker”.

Your goal is to create a program that gathers the employee’s name, marital status, number of children and whether or not they smoke tobacco for a single employee. While gathering this information, if the user enters at least one invalid value, the program must display one error message telling the user they made a mistake and that they should re-run the program to try again. The program must then end at this point. However, if all valid values are entered, the program should calculate the total cost of the healthcare payroll deduction and then print a well-formatted report that shows the employee’s name, marital status, total number of children, and smoker designation, and total deduction amount.

Write a well-documented, efficient Java program that implements the algorithm you identified. Include appropriate documentation as identified in the documentation expectations document. Note: You must use the JOptionPane class for input/output. Additionally, if you use System.exit as shown in the textbook, it may only be used as the absolute last line in the program. You may not use System.exit, or any variant that exits the program in the middle of the program. The program should be designed to only exit once the algorithm has finished.

Solutions

Expert Solution

thanks for the question, here is the complete code in Java, have used JoptionPane only to input andoutput data.

Below is the code

==============================================================

import javax.swing.*;

public class HealthInsurance {


    public static void main(String[] args) {

        String name = getName();
        boolean isMarried = isMarried();
        double deduction = 150; // base fees
        int childrens = 0;
        if (isMarried) {
            childrens = childrens();
            deduction += 75 + childrens * 50; // 75 for spouse and 50$ for each children

        }
        boolean isSmoker = isSmoker();
        if (!isSmoker) {
            deduction -= deduction * .1; // deduct 10%
        }

        String desc = "Here are the details:\n";
        desc += "\nName: " + name;
        desc += "\nMarried : " + isMarried;
        desc += "\nChildrens : " + childrens;
        desc += "\nSmoker : " + isSmoker;
        desc += "\nHealth Care Deductions : $" + String.format("%.2f", deduction) + "\n";

        JOptionPane.showMessageDialog(null, desc);

    }


    private static String getName() {

        String name = JOptionPane.showInputDialog("Enter name");
        if (name.trim().length() == 0) {
            JOptionPane.showMessageDialog(null,"You didnt entered a valid name. Program will terminate now.");
            System.exit(1);

        }
        return name;
    }

    private static boolean isMarried() {

        String response = JOptionPane.showInputDialog("Are you married (yes/no)? ");
        if (response.trim().length() == 0 || !(response.equalsIgnoreCase("yes") || response.equalsIgnoreCase("no"))) {
            JOptionPane.showMessageDialog(null,"You need to enter either yes or no. " +
                    "You didnt entered a valid response. Program will terminate now.");
            System.exit(1);

        }
        return response.equalsIgnoreCase("yes");
    }

    private static int childrens() {
        int childrenCount = 0;
        String childrens = JOptionPane.showInputDialog("How many childrens do you have: ");
        try {
            childrenCount = Integer.parseInt(childrens);
            if (childrenCount >= 0) return childrenCount;
            else {
                JOptionPane.showMessageDialog(null,"Count cannot be negative. Program will terminate now.");
                System.exit(1);

            }
        } catch (NumberFormatException e) {
            JOptionPane.showMessageDialog(null,"You didnt entered a valid number. Program will terminate now.");
            System.exit(1);
        }
        return 0;
    }

    private static boolean isSmoker() {

        String response = JOptionPane.showInputDialog("Do you smoke tobacco (yes/no)? ");
        if (response.trim().length() == 0 || !(response.equalsIgnoreCase("yes") || response.equalsIgnoreCase("no"))) {
            JOptionPane.showMessageDialog(null,"You need to enter either yes or no. " +
                    "You didnt entered a valid response. Program will terminate now.");
            System.exit(1);

        }
        return response.equalsIgnoreCase("yes");
  }

}


Related Solutions

The Human Resources Department of a company conducts a survey to determine if a new medical...
The Human Resources Department of a company conducts a survey to determine if a new medical insurance plan is viewed favorably. Out of 200 employees surveyed 80 said they liked the change.    a. Calculate a 95% confidence interval for the population proportion who view the change favorably. b. What is the proper interpretation of the interval constructed in Part a? i. There is a 95% chance that the population proportion lies within the constructed interval. ii. If 20 similar...
The human resources department needs to forecast the number of sexual harassement investigations for the entire company.
  The human resources department needs to forecast the number of sexual harassement investigations for the entire company. The data for several months is supplied below. Be careful since the data is listed beginning with the most recent. The forecasting method to be used here is the 4 month weighted moving average adjusting for seasonality where the weights, starting with the most recent time period, are 0.4, 0.3, 0.2, 0.1. Again, you must find the seasonality factors for the data....
Why human resources planning needs for the company? What is impact of human resources planning to...
Why human resources planning needs for the company? What is impact of human resources planning to business objectives?
How the Human Resources Department rewards the employees?
How the Human Resources Department rewards the employees?
The human resources department of a very large organisation is trying to determine the proportion of...
The human resources department of a very large organisation is trying to determine the proportion of all employees that are satisfied with their current position. They randomly select 121 employees and ask them: "Are you satisfied with your current position?" 61 replied yes they were. Construct a 95% confidence interval to estimate the true proportion of all employees at this workplace who were satisfied with their position. A 95% confidence interval for the true proportion of all employees at this...
How much Human Resources cost would be allocated to Cafeteria?
Marshall Welding Company has two service departments (Cafeteria and Human Resources) and two production departments (Machining and Assembly). The number of employees in each department follows. cafeteria 20 human resources 30 machining 100 assembly 150 Marshall Welding uses the step-down method of cost allocation and allocates cost on the basis of employees. Human Resources cost amounts to $1,200,000, and the department provides more service to the firm than Cafeteria. How much Human Resources cost would be allocated to Cafeteria? a....
How would a human resources department use information in the operating budgets?
How would a human resources department use information in the operating budgets?
Scheherazade is using the needs approach to determine how much life insurance to buy. Her needs...
Scheherazade is using the needs approach to determine how much life insurance to buy. Her needs are as follows: cash needs $130,000; income needs $780,000; special needs $100,000. Scheherazade has the following assets: cash $20,000, retirement plans $175,000, securities $35,000. She owns no individual life insurance but has an $85,000 group life policy through her employer. Based on this information, how much additional life insurance should Scheherazade purchase? Be sure to show your calculations.
Making Human Resource Decisions Scenario: You are the Director of Human Resources for your company. The...
Making Human Resource Decisions Scenario: You are the Director of Human Resources for your company. The CEO has just informed you that the financial state of the company is dire, and as a result, he is approaching the managers of each department and asking them to reduce personnel costs. The company makes its profits primarily on services such as business consulting, cloud-based storage for large companies, and other small miscellaneous business products. The industry has become highly competitive and sales...
The director of Human Resources at a large company wishes to determine if newly instituted training...
The director of Human Resources at a large company wishes to determine if newly instituted training has been effective in reducing work-related injuries. In a random sample of 100 employees taken from the six months before this training began (group 1), she found 15 had suffered a work-related injury. Using a random sample of 150 employees from the six months since the training began (group 2), she found 12 had suffered a work-related injury. a) Find the 95% confidence interval...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT