0% found this document useful (0 votes)
218 views9 pages

Bmi - Python Project

This document describes a Java program that calculates BMI (Body Mass Index) based on a user's weight and height input. It includes chapters on the introduction to BMI, the modules and functions used in the Java code, the source code itself, and examples of output. The code takes weight and height as input, calculates the BMI value, and interprets the BMI to indicate if the user is underweight, normal, overweight, or obese.

Uploaded by

bjbhargav600
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
218 views9 pages

Bmi - Python Project

This document describes a Java program that calculates BMI (Body Mass Index) based on a user's weight and height input. It includes chapters on the introduction to BMI, the modules and functions used in the Java code, the source code itself, and examples of output. The code takes weight and height as input, calculates the BMI value, and interprets the BMI to indicate if the user is underweight, normal, overweight, or obese.

Uploaded by

bjbhargav600
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

VISVESVARAYA TECHNOLOGICAL UNIVERSITY

JNANA SANGAMA, BELGAVI-590018

OBJECT ORIENTED PROGRAMMING WITH JAVA


(BCS306A)

ASSIGNMENT ON

“BMI CALCULATOR USING JAVA”

Submitted in partial fulfillment of the requirements for the


3rd Semester

INFORMATION SCIENCE AND ENGINEERING

Submitted by

BHARGAV B J

1BI22IS019

CHIRAYU SHARMA GK

1BI22IS021

Under the Guidance of

PRIYA N V
Assistant Professor
Dept of ISE, BIT

BANGALORE INSTITUTE OF TECHNOLOGY


K R Road, V V Puram, Bengaluru-560004
DEPARTMENT OF INFORMATION SCIENCE & ENGINEERING
2022-2023
BMI CALCULATOR

TABLE OF CONTENTS

CHAPTER TITLE PAGE NO.


NO.
1 INTRODUCTION 1
2 IMPLEMENTATIONS 3

3 SOURCE CODE 5
4 OUTPUT 7

Dept Of ISE,BIT 2023-24


BMI CALCULATOR

CHAPTER 1

INTRODUCTION TO BMI

A Body Mass Index (BMI) calculator is a mathematical tool used to assess an individual's
body composition and determine whether their weight falls within a healthy range for
their height. It is a simple and widely used method for estimating a person's overall body
fat based on a mathematical formula involving their weight and height. The BMI formula
is as follows:

BMI = weight(kg)/height(m)^2
Where:

● BMI is the Body Mass Index,

● Weight is measured in kilograms (kg),

● Height is measured in meters (m).

The BMI calculator provides a numeric value, which can then be interpreted using standardized
categories to assess whether a person is underweight, normal weight, overweight, or obese. These
categories typically fall within the following ranges:

● BMI less than 18.5: Underweight

● BMI between 18.5 and 24.9: Normal weight

● BMI between 25.0 and 29.9: Overweight

● BMI greater than or equal to 30.0: Obese

While the BMI calculator is a useful tool for quickly assessing body weight relative to height, it does
have certain limitations. It does not take into account factors such as muscle mass, bone density,
age, gender, or distribution of weight, all of which can affect an individual's health and risk
factors.

Dept Of ISE,BIT 2023-24 1


BMI CALCULATOR

Therefore, it is crucial to consider BMI results in conjunction with other health assessments
and consult with a healthcare professional for a more comprehensive evaluation.

In the field of Boolean algebra, BMI calculators do not directly relate to its principles.
Boolean algebra deals with binary logic and is primarily used in computer science and
mathematics for logical operations and circuit design. The BMI calculator is more related to
basic arithmetic and statistics, focusing on assessing physical health rather than logical
operations.

Dept Of ISE,BIT 2023-24 2


BMI CALCULATOR
CHAPTER 2

MODULES AND FUNCTIONS


In the provided Java code for the BMI calculator, there are no modules or functions in the same sense
as in some other programming languages like Python, which have explicit module and function
constructs. However, in Java, we have classes and methods which serve similar purposes.

Functions:

1.Import Statement:
import java.util.Scanner;

This line imports the Scanner class from the java.util package. The Scanner class is used to obtain
user input from the console.

2.Class Declaration:
public class BMICalculator {

 This line declares a class named BMICalculator. In Java, a class is a blueprint for objects.

3.Main Method:
public static void main(String[] args) {

 This line declares the main method. In Java, the execution of a program starts from the main
method.

 The String[] args parameter allows the program to accept command-line arguments.

4.Creating a Scanner Object:

Scanner scanner = new Scanner(System.in);

 This line creates an instance of the Scanner class, which is used to read input from the standard
input stream (usually the keyboard).

Dept Of ISE,BIT 2023-24 3


BMI CALCULATOR

5.User Input:

double weight = scanner.nextDouble();


double height = scanner.nextDouble();

 These lines prompt the user to input their weight and height, which are then stored in variables
weight and height, respectively.
6.BMI Calculation Method:
public static double calculateBMI(double weight, double height)
{
return weight / (height * height);
}
 This method calculates the BMI using the formula: BMI = weight / (height * height).
It takes two parameters: weight and height, both of type double.
 It returns the calculated BMI as a double value.

7.Displaying the Result:

System.out.println("Your BMI is: " + bmi);

 This line displays the calculated BMI to the user.

8.Closing the Scanner:

scanner.close();

 This line closes the Scanner object to release system resources.

Dept Of ISE,BIT 2023-24 4


BMI CALCULATOR

CHAPTER 3

CODE
import java.util.Scanner;

public class BMICalculator {

public static void main(String[] args) {


// Create a Scanner object for user input
Scanner scanner = new Scanner(System.in);

// Prompt the user to enter their weight in kilograms


System.out.print("Enter your weight in kilograms: ");
double weight = scanner.nextDouble();

// Prompt the user to enter their height in meters


System.out.print("Enter your height in meters: ");
double height = scanner.nextDouble();

// Calculate BMI using the formula: BMI = weight / (height * height)


double bmi = calculateBMI(weight, height);

// Display the calculated BMI to the user


System.out.println("Your BMI is: " + bmi);

// Interpret BMI value and provide context


interpretBMI(bmi);

// Close the Scanner object


scanner.close();
}

Dept Of ISE,BIT 2023-24 5


BMI CALCULATOR

// Method to calculate BMI


public static double calculateBMI(double weight, double height)
{
return weight / (height * height);
}

// Method to interpret BMI and provide context


public static void interpretBMI(double bmi)
{
if (bmi < 18.5)
{
System.out.println("You are underweight.");
}
else if (bmi >= 18.5 && bmi < 25)
{
System.out.println("You are normal weight.");
}
else if (bmi >= 25 && bmi < 30)
{
System.out.println("You are overweight.");
}
else
{
System.out.println("You are obese.");
}
}
}

Dept Of ISE,BIT 2023-24 6


BMI CALCULATOR

CHAPTER 4
OUTPUT

OUTPUT 1:

OUTPUT 2:

Dept Of ISE,BIT 2023-24 7

You might also like