Question

In: Computer Science

Your Java program should perform the following things:Take the input from the user about the...

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.

    1. If the BMI Score is less than 18.5, then underweight.

    2. If the BMI Score is between 18.5-24.9, then Normal.

    3. If the BMI score is between 25 to 29.9, then Overweight.

    4. If the BMI score is greater than 29.9, then Obesity.

  4. Calculate Insurance Payment Category based on BMI Category.

    1. If underweight, then insurance payment category is low.

    2. If Normal weight, then insurance payment category is low.

    3. If Overweight, then insurance payment category is high.

    4. If Obesity, then insurance payment category is highest.

  5. Implement exception handling using try-catch.

  6. Include the finally block.

You need to submit the following things:

  • An entire Java solution

  • An output screenshot created using Microsoft Word

Solutions

Expert Solution

/*************************************BMI.java************************************/

import java.util.Scanner;

public class BMI {

   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);
       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 excepetion 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();
       } 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);
       String bmiCategory = "";
       String insuranceCategory = "";
       /*
       * set BMI category as BMI set Insurance Payment category as BMI category
       */
       if (bmi <= 18.5) {
           bmiCategory = "underweight";
           insuranceCategory = "Low";
       } else if (bmi > 18.5 && bmi <= 24.9) {
           bmiCategory = "Normal";
           insuranceCategory = "Low";
       } else if (bmi > 25 && bmi <= 29.9) {
           bmiCategory = "Overweight";
           insuranceCategory = "High";
       } else if (bmi > 29.9) {
           bmiCategory = "Obesity";
           insuranceCategory = "Highest";
       }
       scan.close();
       /*
       * Print the patient name and date of birth print the patient BMI category print
       * the patient insurance payment category
       */
       System.out.println("Patient " + name + "and Date of birth is - " + birthDate + "\nPatient BMI category is - "
               + bmiCategory);
       System.out.println("And Patient insurance payment category is - " + insuranceCategory);
   }
}

/*******************************output***********************************/

Please enter patient name: Virat Kohli
Please enter the weight of the patient in kg: 78
Please entet the birth date of patient: 05/10/1993
Please enter the height of patient in cm: 178
Welcome to BMI calculator!!
Patient Virat Kohliand Date of birth is - 05/10/1993
Patient BMI category is - Normal
And Patient insurance payment category is - Low


Related Solutions

JAVA Take in a user input. if user input is "Leap Year" your program should run...
JAVA Take in a user input. if user input is "Leap Year" your program should run exercise 1 if user input is "word count" your program should run exercise 2 Both exercises should run in separate methods Exercise 1: write a java method to check whether a year(integer) entered by the user is a leap year or not. Exercise 2: Write a java method to count all words in a string.
Write a Java program that reads an input graph data from a user. Then, it should...
Write a Java program that reads an input graph data from a user. Then, it should present a path for the travelling salesman problem (TSP). In the assignment, you can assume that the maximum number of vertices in the input graph is less than or equal to 20. Input format: This is a sample input from a user. 4 12 0 1 2 0 3 7 0 2 5 1 0 2 1 2 8 1 3 3 2 0...
write a program to perform the following in C Your program should prompt the user to...
write a program to perform the following in C Your program should prompt the user to enter ten words, one at a time, which are to be stored in an array of strings. After all of the words have been entered, the list is to be reordered as necessary to place the words into alphabetical order, regardless of case. Once the list is in alphabetical order, the list should be output to the console in order. The program should execute...
Write an assembly language program to input a string from the user. Your program should do...
Write an assembly language program to input a string from the user. Your program should do these two things: ***** I AM POSTING THIS QUESTION FOR THE THIRD TIME NOW,I WANT IT DONE USING INCLUDE IRVINE32.INC***** 1. count and display the number of words in the user input string. 2. Flip the case of each character from upper to lower or lower to upper. For example if the user types in:   "Hello thEre. How aRe yOu?" Your output should be:...
Write Java program that asks a user to input a letter, converts the user input to...
Write Java program that asks a user to input a letter, converts the user input to uppercase if the user types the letter in lowercase, and based on the letter the user the user enters, display a message showing the number that matches the letter entered. For letters A or B or C display 2 For letter D or E or F display 3 For letter G or H or I display 4 For letter J or K or L...
Write a program that encrypts and decrypts the user input. Note – Your input should be...
Write a program that encrypts and decrypts the user input. Note – Your input should be only lowercase characters with no spaces. Your program should have a secret distance given by the user that will be used for encryption/decryption. Each character of the user’s input should be offset by the distance value given by the user For Encryption Process: Take the string and reverse the string. Encrypt the reverse string with each character replaced with distance value (x) given by...
User the Scanner class for your input Write a java program to calculate the area of...
User the Scanner class for your input Write a java program to calculate the area of a rectangle. Rectangle Area is calculated by multiplying the length by the width   display the output as follow: Length =   Width = Area = Load: 1. Design (Pseudocode ) 2. Source file (Java file, make sure to include comments) 3. Output file (word or pdf or jpig file)
Write a C++ or Java program that reads an input graph data from a user. Then,...
Write a C++ or Java program that reads an input graph data from a user. Then, it should present a path for the travelling salesman problem (TSP). In the assignment, you can assume that the maximum number ofvertices in the input graph is less than or equal to 20. Input format: This is a sample input from a user. 4 12 0 1 2 0 3 7 0 2 5 1 0 2 1 2 8 1 3 3 2...
(JAVA) Create a program that prompts the user for an age input. The program defines the...
(JAVA) Create a program that prompts the user for an age input. The program defines the age group of the user. Follow the table below to construct the output for your program. Age Age Group 0 Baby 1-3 Toddler 4-11 Child 12-17 Teenager 18-21 Young Adult 22-64 Adult 65+ Senior Negative Number Invalid Input Sample Input Enter an age: 18 Sample Output: You are a young adult. Sample Input Enter an age: 29 Sample Output: You are an adult. Sample...
JAVA: Write a program that prompts the user to input a type of medication and the...
JAVA: Write a program that prompts the user to input a type of medication and the output will be a list of side effects that can occur from that medication.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT