Background Employees often have to pick among several health insurance plans off
ID: 3838679 • Letter: B
Question
Background
Employees often have to pick among several health insurance plans offered by their employer. Different plans are better for different circumstances, like whether or not you are covering a family and the amount of doctor visits you expect to make. For our purposes, there are three attributes of an insurance plan that are important:
The premium: this is how much you have to pay for a year of insurance.
The deductible: this is how much you have to pay for your doctor's bills before insurance will start paying anything. For example, if you have a $1000 deductible, then your first $1000 worth of doctor's bills during the year will be your responsibility to pay. If you have less than $1000 in expenses during the year, then your insurance will not pay anything toward your bills. Otherwise, you pay the first $1000 and you and your insurance company split the cost for the rest of the bills. How those bills are split is determined by the...
The coinsurance: this is a percentage, like 20%. After you have "met your deductible"--that is, paid doctor's bills totaling your deductible amount--then the remaining bills for that year are split. You pay the coinsurance, and your insurance company covers the rest.
Here are a few examples:
1. My plan has $5000 premium, $1000 deductible, and 20% coinsurance.
If I have no medical bills, then my health care costs are $5000 (i.e., just the premium).
If I have $500 in medical bills, then I pay all of those (because they are less than the deductible), plus the premium. My health care costs are $5500.
If I have $1002 in medical bills, then I pay the premium, plus my $1000 deductible, plus 20% of the bills over the deductible (20% of $2 is $0.40). Thus, my health care costs are $6000.40.
If I have $15000 in medical bills, then I pay the premium, plus my $1000 deductible, plus 20% of the bills over the deductible (20% of $14000 is $2800). Thus, my health care costs are $8800.
2. In scenario 2, suppose my plan has $3000 premium, $4000 deductible, and 25% coinsurance.
If I have no medical bills, then my health care costs are $3000 (i.e., just the premium).
If I have $500 in medical bills, then I pay all of those (because they are less than the deductible), plus the premium. My health care costs are $3500.
If I have $1002 in medical bills, then I pay all of those (because they are less than the deductible), plus the premium. My health care costs are $4002.
If I have $15000 in medical bills, then I pay the premium, plus my $4000 deductible, plus 25% of the bills over the deductible (25% of $11000 is $2750). Thus, my health care costs are $9750.
Project Description
For this project, you will build a program that computes the health care costs given the premium, deductible, coinsurance, and total medical bills. We will be working with two pre-defined health care plans, as well as letting the user enter their own parameters. Here are the two plans:
Premium
Deductible
Coinsurance
Alphex
$5000
$1000
20%
Glamron
$3000
$4000
25%
Analysis
As you gain experience with programming, you will be able to analyze the description above and create a program to compute the health care costs. In this first project, however, we will guide you through the analysis part and help you design your program.
One of the first steps in analysis is determining the inputs that your program needs and the outputs it will produce. Before reading the next part of the description, take a minute to write down the inputs and outputs.
You should have written down the following:
Inputs: Premium, deductible, coinsurance, amount of medical bills
Output: health care costs
Design
As with the analysis, as you gain experience with programming you will reach the point where you can complete the design on your own. This is where you figure out the algorithm (i.e., the steps the computer needs to take) for computing the health care costs for a given premium, deductible, coinsurance, and amount of medical bills. You can use the definitions and examples above to figure this out, along with the requirements that follow.
Your program should meet the following specifications. (The amount of points for each part is in square brackets).
[10 pts] As with all your code, correct compilation is critical.
Commenting and style
[3 pts] Comments should be clearly written with correct grammar and spelling.
[3 pts] Indentation and general appearance should be consistent and make the code easy to read.
[2 pts] You should write a comment for each major piece of computation. For example,
// Determine the health care plan
[2 pts] You should also write a comment at the top of your file with the following content:
/*
* <your name>
* CS16000 Spring 2015
* Project 1: Health Care Calculator
*
* Description: <summarize the purpose of the program here>
*/
[1 pt] The program should consist of one class, called HealthCareCalculator
[1 pt] The class should contain only the main method.
Variables in the main method
[5 pts] The main method should include variables called premium, deductible, coinsurance, and bills. You should determine the appropriate types for those variables.
[5 pts] It should also contain variables for each attribute of the two health care plans listed above (i.e., 6 variables total). Choose clear, understandable names for these variables. These should be named constants (i.e., there is a Java keyword to make these constants). This is the only place where you should use numeric constants in your program.
You can define other variables as needed, but they must all be within the main method.
The main method should carry out the following tasks in this order:
Declare variables as needed
[2 pts] Declare and instantiate a Scanner object to read data from the console
[6 pts] Solicit the health care plan name from the user via the console with the message "Enter the name of the health care plan: "
[8 pts] Run a switch statement on the plan name. The valid values are "Alphex", "alphex", "Glamron", "glamron", "User", or "user".
[4 pts] If the user enters something else for the plan name, print out an error message to the console ("Invalid plan. Exiting the program.") and exit the program.
Assign values for premium, deductible, and coinsurance.
§ [3 pts] If "Alphex" or "Glamron" (or either lower-case version) was selected, set premium, deductible, and coinsurance from the other variables in your program.
§ [12 pts] If the "User" (or "user") plan was selected, solicit the three attributes using three JOptionPane input dialogs, storing the values in premium, deductible, and coinsurance. You should accept coinsurance as a fractional value. For example, if the user enters "0.2", that represents 20% coinsurance.
Note that at this point in your program, premium, deductible, and coinsurance should have the proper values, regardless of which plan was selected. This is a step toward modularity, an important principle in computer science: the rest of the program does not need to know what plan was selected; it can proceed by using those three variables alone.
[6 pts] Solicit the amount of medical bills from the user via the console, using the message "Enter the amount of medical bills: "
[15 pts] Calculate the health care costs (premium + amount toward deductible + any coinsurance costs). You should use an if statement to check if the bills are more than the deductible.
[8 pts] Display the results to the console. The message should include the premium, the other costs, and the total, formatted like Premium: $5000.00 Other costs: $428.20 Total costs: $5428.20
[4 pts] Note that all of the dollar amounts should be rounded to the nearest cent, and all amounts should display two digits on the right of the decimal point. All of the calculations in your program should support cents, but do not round until the final output. You can use System.out.printf to format your results.
Premium
Deductible
Coinsurance
Alphex
$5000
$1000
20%
Glamron
$3000
$4000
25%
Explanation / Answer
/*
* <your name>
* CS16000 Spring 2015
* Project 1: Health Care Calculator
*
* Description: Need to claculate the bill to be paid by employee based on the insurance plan selected
*/
package healthCare;
import java.util.Scanner;
import javax.swing.JOptionPane;
public class HealthCareCalculator {
public static void main(String[] args) {
// TODO Auto-generated method stub
Integer alphex_Premium=5000;//pre-defined value premium value for Alphex plan
Integer alphex_Deductible=1000;//pre-defined value Deductible value for Alphex plan
Integer alphex_Coinsurance=20;//pre-defined value Coinsurance value for Alphex plan
Integer glamron_Premium=3000;//pre-defined value premium value for Glamron plan
Integer glamron_Deductible=4000;//pre-defined value Deductible value for Glamron plan
Integer glamron_Coinsurance=25;//pre-defined value Coinsurance value for Glamron plan
Double bills=0.0;
Integer premium=0;
Integer deductible=0;
Integer coinsurance=0;
Scanner scanner = new Scanner(System.in);//Scanner Object
System.out.println("Enter the name of the health care plan:");
String planName=scanner.nextLine();//Reads the plan type from console
switch (planName) {//Switch case to assign a proper values to variables based on plan selected
case "Alphex":
premium=alphex_Premium;
deductible=alphex_Deductible;
coinsurance=alphex_Coinsurance;
break;
case "alphex":
premium=alphex_Premium;
deductible=alphex_Deductible;
coinsurance=alphex_Coinsurance;
break;
case "Glamron":
premium=glamron_Premium;
deductible=glamron_Deductible;
coinsurance=glamron_Coinsurance;
break;
case "glamron":
premium=glamron_Premium;
deductible=glamron_Deductible;
coinsurance=glamron_Coinsurance;
break;
case "User":
premium= new Integer(JOptionPane.showInputDialog("Please Enter premium"));//GUI for premium input from user
deductible= new Integer(JOptionPane.showInputDialog("Please Enter deductible"));//GUI for deductible input from user
coinsurance= new Integer((int) (new Double(JOptionPane.showInputDialog("Please Enter coinsurance"))*100));//GUI for coinsurance input from user and converts fraction value to integer
break;
case "user":
premium= new Integer(JOptionPane.showInputDialog("Please Enter premium"));
deductible= new Integer(JOptionPane.showInputDialog("Please Enter deductible"));
coinsurance= new Integer((int) (new Double(JOptionPane.showInputDialog("Please Enter coinsurance"))*100));
break;
default://If user selects any other plan than listed
System.out.println("Invalid plan. Exiting the program.");
return;//Exists from the program
}
System.out.println("Enter the amount of medical bills:");
Integer medicalBillAmount=scanner.nextInt();
if(medicalBillAmount<=deductible)// when medicalbill amount entered is less than deductible value
{
bills=premium+medicalBillAmount.doubleValue();
}
if(medicalBillAmount>deductible)// when medicalbill amount entered is more than deductible value
{
bills=premium+deductible+(((medicalBillAmount-deductible)*coinsurance)/100.00);
}
System.out.println("Premium: $"+premium+" Other Costs: $"+(bills-premium)+" Total Costs: $"+bills);
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.