Program for finding Body Mass Index Using JAVA


/*
 * BODY MASS INDEX
 * It is a numeric indicator of human body fat based on a person weight and height.It is applicable to adult men
 * and women and is mainy used to screen indivduals in order to detect potential weight problems.
 * The common formulafor calculating BMI = Mass(Kg)/[height(m)]^2
 * It was invented by Begian Scinetist Adolphe Quetelet and hence it is also known as the Quetelet Index.
 * A BMI of 18.5 to 24.9 is considered normal.
 */
package Snlkjha;
import javax.swing.*;

/**
 * @author Snlkjha
 */
public class BodyMassIndex {

    public static void main(String[] args) {
       
        String wt = JOptionPane.showInputDialog("Enter Weight(In Kg):");
        String ht = JOptionPane.showInputDialog("Enter Height(In Inch):");
        double weight = Double.valueOf(wt).doubleValue();
        double height = Double.valueOf(ht).doubleValue();
        double m_height = (height) / (39.37);
        double body_mass_index = weight / (m_height * m_height);
        if (body_mass_index >= 18.5 && body_mass_index <= 24.9) {
            JOptionPane.showMessageDialog(null, "Congratulations...!!!\nYour Body Mass Index Is Normal.\nYour BMI is " + body_mass_index + " Kg/m^2");
        } else if (body_mass_index < 18.5) {
            double gain=(18.5*m_height*m_height)-weight;
            JOptionPane.showMessageDialog(null, "Be Concious...!!!\nYour BMI is " + body_mass_index + " Kg/m^2\nYour Body Mass Index Is Not Normal U exacly need to gain your weight by "+gain+" Kg. in order to achieve minimum normal level.");
        } else {
            double lose=weight-(24.9*m_height*m_height);
            JOptionPane.showMessageDialog(null, "Be Alert...!!!\nYour BMI is " + body_mass_index + " Kg/m^2\nYour Body Mass Index Is Not Normal U exactly need to  lose Ur Weight by "+lose+" Kg. in order to achieve maximum normal level.");
        }
    }
}

Popular posts from this blog

8 Bit Plane Slicing of an image in Image Processing

Code to upload multiple files simultaneously using JSP, Servlet .

STRING PALINDROME USING STACK AND QUEUE