Total members 10262 | Gratitudes |It is currently Thu May 24, 2012 9:53 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 1 post ] 
Author Question
 Question subject: javascript help with BMI
PostPosted: Sun Jun 21, 2009 6:04 am 
Offline
Newbie
User avatar

Joined: Sun Jun 21, 2009 5:50 am
Posts: 1
Has thanked: 0 time
Have thanks: 0 time

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>


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 1 post ] 
Quick reply


  

 Similar topics
 JavaScript fade out problem
 javascript read file
 getting gst, pst total to diplay in my javascript form
 need help with javascript
 Javascript select menu validation issue
 validate age entered as selection box in javascript
 Trim string in JavaScript
 check array contains a value using javascript
 Javascript Multi-dimensional Arrays
 print clock using JavaScript

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 1 guest



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team