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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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 tasks:

1. Take input from the user regarding the patient’s name, weight, birthdate, and height.
2. Calculate the Body Mass Index (BMI).
3. Display the person’s 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 the Insurance Payment Category based on the BMI Category.
   - a. If underweight, the insurance payment category is low.
   - b. If Normal weight, the insurance payment category is low.
   - c. If Overweight, the insurance payment category is high.
   - d. If Obesity, the insurance payment category is highest.
5. Implement exception handling.
6. Store all the information in a file. Use a loop to continuously ask 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 the user enters the "q" character.

You need to submit the following items:

- 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 tasks: 1. Take input from the user regarding the patient’s name, weight, birthdate, and height. 2. Calculate the Body Mass Index (BMI). 3. Display the person’s 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 the Insurance Payment Category based on the BMI Category. - a. If underweight, the insurance payment category is low. - b. If Normal weight, the insurance payment category is low. - c. If Overweight, the insurance payment category is high. - d. If Obesity, the insurance payment category is highest. 5. Implement exception handling. 6. Store all the information in a file. Use a loop to continuously ask 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 the user enters the "q" character. You need to submit the following items: - 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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education