Total members 11890 |It is currently Sat Apr 20, 2024 2:24 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Hi everyone, I'm a mature age TAFE student in Australia and I'm learning JavaScript as part of a Interactive Digital Media $ course and I'm having trouble getting a BMI script working. I've got the calculations working but the If and If Else statements aren't working. Can someone check it out for me please as I've got a test 2moro and really need this to work.
I know it should be easy, I can't see my mistake, any help would be greatly appreciated.

thanks michael


here's my code


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>

<script type="text/javascript" language="javascript1.5">

//declare variables
var height
var weight
var numHeight
var numWeight
var bmi


//get user to enter height
height = window.prompt("Enter your height in centimetres ","");
//convert to number
numHeight = parseInt(height);
//get user to enter their weight
weight = window.prompt("Enter your weight in Kilograms ","");
//convert to number
numWeight = parseInt(weight);
//convert to metres
height = height/100;
//calculate bmi
bmi = weight/(height * height);
//round down bmi
bmiRounded = Math.round(bmi)
//display height, weight and bmi
{
document.writeln("Your entered height is ", + numHeight + " centimetres");
}
{
document.write("<br/>Your entered weight is ", + numWeight + " metres");
}
{
document.writeln("<br/>Your Body Mass Index is ", + bmiRounded + "");
}

//determine weight classification
if else(bmi<50)
{
document.writeln("You are<strong>Underweight</strong> eat more!");
{
if else(bmi>=30)
}
document.writeln("You are<strong>Obese</strong> see a doctor!");
}
if else(bmi>=25)
{
document.writeln("You are<strong>Overweight</strong> exercise more!");
}
if else(bmi>=18.5)
{
document.writeln("Your weight is <strong>Normal</strong> Congratulations!");
{
//display weight classification
document.writeln("<br/>Your BMI places you in the " + clss + "classification");
if else((numWeight<50) || (numHeight>2.2))
{
document.writeln("<br/>Your weight is less than 50 or your height is more tha 2.2metres.<br/>This result may be innacurate.");
}
do
{
height = window.prompt("","");

numWeight = parseInt(height);
while((numHeight) || isNaN(numHeight) || (numHeight>0));
}


</script>
</html>




Author:
Newbie
User avatar Posts: 1
Have thanks: 0 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : javascript help with BMI
 need help with javascript     -  
 what is javascript ?     -  
 JavaScript     -  
 i need help in javascript     -  
 When to use javascript?     -  
 Javascript     -  
 using javascript     -  
 need help in javascript     -  
 Ajax without javascript     -  
 PHP variable in javascript     -  









Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com