Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package bmi_calculator;
- import java.util.Scanner;
- public class BMI_Calculator {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- System.out.println("*************** Healthy Life ***************\n"
- + "1--> Start\n"
- + "0--> Exit\n"
- + "-------------------------");
- System.out.print("Enter your choice: ");
- int choice = scanner.nextInt();
- while (choice != 0) {
- if (choice == 1) {
- System.out.print("Enter weight: ");
- int weight = scanner.nextInt();
- System.out.print("Enter height: ");
- double height = scanner.nextDouble();
- int bmi = (int) (weight / (height * height));
- System.out.println("BMI is --> " + bmi);
- if (bmi < 18.5) {
- System.out.println("You are underweight!");
- } else if (bmi >= 18.5 && bmi <= 24.9) {
- System.out.println("You have normal weight");
- } else if (bmi >= 25 && bmi <= 29.9) {
- System.out.println("You are overweight");
- } else {
- System.out.println("You are obesity");
- }
- } else {
- System.out.println("Invalid choice.");
- }
- System.out.println("****************************");
- System.out.println("Do you want to Continue?\n"
- + "1--> Continue\n"
- + "0--> Exit\n"
- + "-------------------------");
- System.out.print("Enter your choice: ");
- choice = scanner.nextInt();
- }
- System.out.println("Good Bye");
- }
- }
Add Comment
Please, Sign In to add comment