You are working as a software developer for a large insurance company. Your company is planning to migrate the existing systems from Visual Basic to Java and this will require new calculations. You will be creating a program that calculates the insurance payment category based on the BMI score.

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter2: Elements Of High-quality Programs
Section: Chapter Questions
Problem 1GZ
icon
Related questions
Question

I have this so far on the project, now I need to add exception handling...please help me complete my ongoing project...thanks!

You are working as a software developer for a large insurance company. Your company is planning to
migrate the existing systems from Visual Basic to Java and this will require new calculations. You will be
creating a program that calculates the insurance payment category based on the BMI score.
Your Java program should perform the following things:
1. Take the input from the user about the patient name, weight, birthdate, and height.
2. Calculate Body Mass Index.
3. Display person name and BMI Category.
a. If the BMI Score is less than 18.5, then underweight.
b. If the BMI Score is between 18.5-24.9, then Normal.
c. If the BMI score is between 25 to 29.9, then Overweight.
d. If the BMI score is greater than 29.9, then Obesity.
4. Calculate Insurance Payment Category based on BMI Category.
a. If underweight, then insurance payment category is low.
b. If Normal weight, then insurance payment category is low.
c. If Overweight, then insurance payment category is high.
d. If Obesity, then insurance payment category is highest.
5. Implement exception handling.
6. Store all the information in the file. You need to use the loop and keep asking users to enter patient
name, height, weight, and birthdate. Your program should calculate BMI Category and Insurance
payment category and write it to the file. Your program should stop once user enter q character.
You need to submit the following things:
• An entire Java solution
• An output screenshot created using Microsoft Word
Transcribed Image Text:You are working as a software developer for a large insurance company. Your company is planning to migrate the existing systems from Visual Basic to Java and this will require new calculations. You will be creating a program that calculates the insurance payment category based on the BMI score. Your Java program should perform the following things: 1. Take the input from the user about the patient name, weight, birthdate, and height. 2. Calculate Body Mass Index. 3. Display person name and BMI Category. a. If the BMI Score is less than 18.5, then underweight. b. If the BMI Score is between 18.5-24.9, then Normal. c. If the BMI score is between 25 to 29.9, then Overweight. d. If the BMI score is greater than 29.9, then Obesity. 4. Calculate Insurance Payment Category based on BMI Category. a. If underweight, then insurance payment category is low. b. If Normal weight, then insurance payment category is low. c. If Overweight, then insurance payment category is high. d. If Obesity, then insurance payment category is highest. 5. Implement exception handling. 6. Store all the information in the file. You need to use the loop and keep asking users to enter patient name, height, weight, and birthdate. Your program should calculate BMI Category and Insurance payment category and write it to the file. Your program should stop once user enter q character. You need to submit the following things: • An entire Java solution • An output screenshot created using Microsoft Word
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

please fix code to match "enter patients name in lbs"

 

thank you

import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

interface Patient {

    public String displayBMICategory(double bmi);

    public String displayInsuranceCategory(double bmi);
}

public class BMI implements Patient {

    public static void main(String[] args) {

        /*
         * local variable for saving the patient information
         */
        double weight = 0;
        String birthDate = "", name = "";
        int height = 0;
        Scanner scan = new Scanner(System.in);
        String cont = "";
        Queue<String> patients = new LinkedList<>();

        // do while loop for keep running program till user not entered q
        do {

            System.out.print("Press Y for continue (Press q for exit!) ");
            cont = scan.nextLine();
            if (cont.equalsIgnoreCase("q")) {

                System.out.println("Thank you for using BMI calculator");
                break;
            }
            System.out.print("Please enter patient name: ");
            /*
             * try catch block for valid data for weight catch block for null value catch
             * block for divide by zero exception if height is zero finally block
             */
            try {
                name = scan.nextLine();
                System.out.print("Please enter the weight of the patient in kg: ");
                weight = scan.nextDouble();
                scan.nextLine();
                System.out.print("Please entet the birth date of patient: ");
                birthDate = scan.nextLine();
                System.out.print("Please enter the height of patient in cm: ");
                height = scan.nextInt();
                scan.nextLine();
            } catch (NumberFormatException e) {
                System.out.println("Please enter valid data!");
            } catch (ArithmeticException e) {
                System.out.println("Height can not be zero!");
            } catch (NullPointerException e) {
                System.out.println("Name can not be blank!");
            } finally {
                System.out.println("Welcome to BMI calculator!!");
            }
            // calculate height in meter
            double heightInMeter = (double) height / 100;
            // calculate BMI
            double bmi = weight / (heightInMeter * heightInMeter);

            /*
             * Print the patient name and date of birth print the patient BMI category print
             * the patient insurance payment category
             */
            Patient patient = new BMI();
            patients.add(name);
            System.out.println("Patient " + name + " and Date of birth is - " + birthDate
                    + "\nPatient BMI category is - " + patient.displayBMICategory(bmi));
            System.out.println("And Patient insurance payment category is - " + patient.displayInsuranceCategory(bmi));
        } while (!cont.equalsIgnoreCase("q"));

        System.out.println("WaitingQueue : " + patients);
        String patientName = patients.remove();
        System.out.println("Removed from WaitingQueue : " + patientName + " | New WaitingQueue : " + patients);
        scan.close();
    }

    @Override
    public String displayBMICategory(double bmi) {
        String bmiCategory = "";
        if (bmi <= 18.5) {
            bmiCategory = "underweight";

        } else if (bmi > 18.5 && bmi <= 24.9) {
            bmiCategory = "Normal";

        } else if (bmi > 25 && bmi <= 29.9) {
            bmiCategory = "Overweight";

        } else if (bmi > 29.9) {
            bmiCategory = "Obesity";

        }
        return bmiCategory;
    }

    @Override
    public String displayInsuranceCategory(double bmi) {
        /*
         * set Insurance Payment category as BMI category
         */
        String insuranceCategory = "";
        if (bmi <= 18.5) {

            insuranceCategory = "Low";
        } else if (bmi > 18.5 && bmi <= 24.9) {

            insuranceCategory = "Low";
        } else if (bmi > 25 && bmi <= 29.9) {

            insuranceCategory = "High";
        } else if (bmi > 29.9) {

            insuranceCategory = "Highest";
        }
        return insuranceCategory;
    }
}

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Introduction to Coding
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr