diff --git a/bmi-calculator/BMICalculator.java b/bmi-calculator/BMICalculator.java new file mode 100644 index 0000000..8edd0da --- /dev/null +++ b/bmi-calculator/BMICalculator.java @@ -0,0 +1,41 @@ +// BMI CALCULATOR USING JAVA - FIRST OPEN SOURCE CONTRIBUTION THROUGH THIS PROJECT + +import java.util.Scanner; + +public class BMICalculator { + public static void main(String[] args) { + // This program calculates BMI based on user input + + Scanner scanner = new Scanner(System.in); + + System.out.println("Welcome to the BMI Calculator!"); + + // Get weight from user + System.out.print("Please enter your weight in kilograms: "); + double weight = scanner.nextDouble(); + + // Get height from user + System.out.print("Please enter your height in meters: "); + double height = scanner.nextDouble(); + + // Calculate BMI + double bmi = weight / (height * height); + + // Print the result + System.out.printf("Your BMI is: %.2f\n", bmi); + + // Interpret the BMI value + if (bmi < 18.5) { + System.out.println("You are underweight."); + } else if (bmi >= 18.5 && bmi < 25) { + System.out.println("You have a normal weight."); + } else if (bmi >= 25 && bmi < 30) { + System.out.println("You are overweight."); + } else { + System.out.println("You are obese."); + } + + // Close the scanner + scanner.close(); + } +} \ No newline at end of file diff --git a/bmi-calculator/README.md b/bmi-calculator/README.md new file mode 100644 index 0000000..0e942ed --- /dev/null +++ b/bmi-calculator/README.md @@ -0,0 +1,34 @@ +# BMI Calculator + +This is a simple Java program that calculates your Body Mass Index (BMI) based on your weight and height. + +## How to Run + +1. Make sure you have Java JDK 21 installed. +2. Open a terminal in this folder. +3. Compile the program: + ``` + javac BMICalculator.java + ``` +4. Run the program: + ``` + java BMICalculator + ``` + +## What It Does + +- Asks you for your weight (in kilograms) and height (in meters) +- Calculates your BMI +- Tells you if you are underweight, normal, overweight, or obese + +## JDK Version + +- OpenJDK Runtime Environment Temurin-21 (or any OpenJDK 21) + +## IDE Used + +- Visual Studio Code (VS Code) + +--- + +*This project was created as a beginner contribution for the Grow-with-Open-Source/Java-Projects repository.*