Skip to main content

help wid my dmi calculator please! ;)

1 reply [Last post]
mbm4ever
Offline
Joined: 2010-08-12

am from the u.k and a newbie to java and i need to create a Body Mass Index Calculator....ive been trying for awhile going through java books but can't seem to get it right....can any one please create a BMI calculator which is really simple and shows weight status table. i have to create this table using Jpad pro....only the javascript code is required so it works without errors when compiled on Jpad pro.

i managed to create this as simple as i can i have ONE ERROR...

<br />
public class BMI<br />
{</p>
<p>public static void main(String[] args) {<br />
int weight; //weight<br />
int height; //height<br />
int BMI; //BMI<br />
char Overweight=0; //Overweight<br />
char Normal_Weight=0; //Normal Weight<br />
char Underweight=0; //Underweight<br />
Scanner input = new Scanner(System.in);</p>
<p>System.out.print("Enter the weight: ");<br />
weight = input.nextInt();<br />
System.out.print("Enter the height: ");<br />
height = input.nextInt();<br />
input.close();</p>
<p>BMI = weight / height;<br />
System.out.println("BMI (Body Mass Index): " + BMI);<br />
if (BMI >= 25 ) {<br />
BMI = Overweight;<br />
System.out.print("BMI = ");<br />
}<br />
}<br />

if anyone can make it any more simple then please do....and also add the the weight status table if its possible

thhanx in advance!

Message was edited by: mbm4ever

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
nomstradamus
Offline
Joined: 2006-09-16

Just Copy paste code below . Don't know about BMI formula is right or not . But code runs fine without any error.

import java.util.Scanner;

public class BMI
{

public static void main(String[] args) {
int weight; //weight
int height; //height
int BMI; //BMI
char Overweight=0; //Overweight
char Normal_Weight=0; //Normal Weight
char Underweight=0; //Underweight
Scanner input = new Scanner(System.in);

System.out.print("Enter the weight: ");
weight = input.nextInt();
System.out.print("Enter the height: ");
height = input.nextInt();
input.close();

BMI = weight / height;
System.out.println("BMI (Body Mass Index): " + BMI);
if (BMI >= 25 ) {
BMI = Overweight;
System.out.print("BMI = ");
}
}
}