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.
Addition of Two Numbers
Adding two numbers in programming is essentially the same as adding two numbers in general arithmetic. A significant difference is that in programming, you need to pay attention to the data type of the variable that will hold the sum of two numbers.
C++
C++ is a general-purpose hybrid language, which supports both OOPs and procedural language designed and developed by Bjarne Stroustrup. It began in 1979 as “C with Classes” at Bell Labs and first appeared in the year 1985 as C++. It is the superset of C programming language, because it uses most of the C code syntax. Due to its hybrid functionality, it used to develop embedded systems, operating systems, web browser, GUI and video games.
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](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F9ca9027d-d44e-49d2-a487-d041a8e79004%2Fdfbec0f0-0bb8-4349-8db6-7be8d4bd7262%2F9t2gn5j_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
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;
}
}
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)