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 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...
Write a simple JAVA program to understand natural language. The user will enter the input following...
Write a simple JAVA program to understand natural language. The user will enter the input following the format: Name came to City, Country in Year. For example: Chris came to Bangkok, Thailand in 2009. The user will follow the exactly the same formats for the inputs. Your program should be able to analyze the key words (Name, City, Country and Year) from the inputs and reorganize the outputs following format: Name stay in City for X year(s). City is in...
Write a Java program named, MultiTable, (MultiTable.java), with the following tasks: Prompt user to input the...
Write a Java program named, MultiTable, (MultiTable.java), with the following tasks: Prompt user to input the maximum number (as integer) Store a multiplication table for all combinations (with some specific eliminations) of value 0 through the maximum number (being entered) into a 2-D array Write a method named printTable to print out the MulitTable, with the following header, public static void printTable(int[][] multitable) In printTable(), when the value of the MultiTable is an odd number, print out Z Must use...
Write a Java program named, TicketSale, (TicketSale.java) with the following tasks: Prompt user to input the...
Write a Java program named, TicketSale, (TicketSale.java) with the following tasks: Prompt user to input the number of Adult tickets to purchase Prompt user to input the number of Children tickets to purchase Prompt user to input the number of Senior tickets to purchase Write a method named, ticketCost(), which will be invoked by main() with statement similar to: cost = ticketCost( adults, children, senior ); Ticket costs structure: $15.00 for each adult $10.00 for each child $5.00 for each...
Write a Java program that prompts the user to input a string and prints whether it...
Write a Java program that prompts the user to input a string and prints whether it is a palindrome. A palindrome is a string which reads the same backward as forward, such as Madam (disregarding punctuation and the distinction between uppercase and lowercase letters). The program must use the stack data structure. The program must include the following classes: The StackX class (or you can use the Java Stack class). The Palindrome class which must contain a method named palindrome()...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT