Question
Using JavaScript You are tasked with writing an application that will keep track of Insurance Policies. You will submit two files (a policy source file
Using JavaScript You are tasked with writing an application that will keep track of Insurance Policies.
You will submit two files (a policy source file and a demo program)
Create a Policy class that will model an insurance policy for a single person.
Use the following guidelines to create the Policy class:
- An insurance policy has the following attributes:
- Policy Number
- Provider Name
- Policyholders First Name
- Policyholders Last Name
- Policyholders Age
- Policyholders Smoking Status (will be smoker or non-smoker)
- Policyholders Height (in inches)
- Policyholders Weight (in pounds)
- Include a no-arg constructor and a constructor that accepts arguments (it must accept all necessary arguments to fully initialize the Policy object)
- Include appropriate setters and getters (i.e., mutator and accessor methods) for each field
- Include a method that calculates and returns the BMI of the policyholder*
- BMI = (Policyholders Weight * 703 ) / (Policyholders Height2 ).
- Include a method that calculates and returns the price of the insurance policy*
- The Insurance Policy has a base fee of $500
- If the Policyholder is over 50 years old, there is an additional fee of $50
- If the Policyholder is a smoker, there is an additional fee of $100
- If the Policyholder has a BMI of over 40, there is an additional fee calculated as follows:
- Additional Fee = ( BMI 40 ) * 50
*Note: this is a calculated amount based on some of the attributes above.
Make sure to avoid having a stale value for this. See "Avoiding Stale Data" in Section 6.2
Demonstrate your Policy class by writing a Demo class. The Demo class should ask the user to enter all necessary information, create a single instance of the Policy class using the constructor that accepts arguments, and then displays all of the information about the policy using the appropriate methods of the Policy class. See the Sample Input and Output below for how to format the input and output of the Demo class (make sure to match the wording and formatting exactly).
Sample Input:
Please enter the Policy Number: 1234
Please enter the Provider Name: State Farm
Please enter the Policyholders First Name: John
Please enter the Policyholders Last Name: Doe
Please enter the Policyholders Age: 24
Please enter the Policyholders Smoking Status (smoker/non-smoker): non-smoker
Please enter the Policyholders Height (in inches): 62.0
Please enter the Policyholders Weight (in pounds): 250.5
Sample Output:
Policy Number: 1234
Provider Name: State Farm
Policyholders First Name: John
Policyholders Last Name: Doe
Policyholders Age: 24
Policyholders Smoking Status: non-smoker
Policyholders Height: 62.0 inches
Policyholders Weight: 250.5 pounds
Policyholders BMI: 45.81
Policy Price: $790.60
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started