Flash Website Builder- Trendy Site Builder is a Flash Site Building tool that helps users build stunning websites. Check Out Custom Custom Logo Design by LogoBee. Website Design and Free Logo Templates available.
 CodingForums.com Mosteller formula confusion

Before you post, read our: Rules & Posting Guidelines

Enjoy an ad free experience by logging in. Not a member yet? Register.
 11-09-2012, 05:58 AM PM User | #1 axel22 New to the CF scene   Join Date: Oct 2012 Posts: 6 Thanks: 2 Thanked 0 Times in 0 Posts Mosteller formula confusion Im trying to figure out/understand about multiple RETURN functions. But, I cant execute my function. Code: ```function SqFeetToSqMeters(sqFeet) { var sqMeters; sqMeters = sqFeet/10.764; return sqMeters; } function PoundsToKilograms(pounds) { var kg; kg = pounds/2.205; return kg; } // function CentimetersToInches(cm) { var inches; inches = cm / 2.54; return inches; } function HEIGHT(surface, weight) {var surface = 'sqMeter'; var weight = 'kg'; height = Math.pow(surface, 2) * 3600) / weight); return height; } function FINDHEIGHT() { var surface, weight, height; surface= parseFloat(document.getElementById('SBox').value); weight = parseFloat(document.getElementById('WBox').value); height= Math.round(HEIGHT(surface,weight)); document.getElementById('HBox').value = height; var str1='Your Height is '; document.getElementById('outputDiv').innerHTML= str1.concat(height); }

Using the Mosteller formula to calculate the height from the body Surface and Weight

surface: sq ft.
weight: pounds
height(calculated): inches

``` Last edited by axel22; 11-09-2012 at 06:56 AM.. Reason: added an OutputDive and added a math.pow for the height formula.
 11-09-2012, 06:25 AM PM User | #2 Old Pedant Supreme Master coder!     Join Date: Feb 2009 Posts: 24,952 Thanks: 75 Thanked 4,307 Times in 4,274 Posts What is the question here? This part of your code makes no sense at all: Code: ``` var surface = ('sqMeter'); var weight = ('kg'); height = Math.round(surface * surface) * 3600) / weight);``` How can you multiply 'sqMeter' * 'sqMeter' and then divide by 'kg'??? __________________ An optimist sees the glass as half full. A pessimist sees the glass as half empty. A realist drinks it no matter how much there is.
 11-09-2012, 06:27 AM PM User | #3 Old Pedant Supreme Master coder!     Join Date: Feb 2009 Posts: 24,952 Thanks: 75 Thanked 4,307 Times in 4,274 Posts If you think you were magically converting surface from square feet to square meters, you weren't All you were doing was assigning the *STRING* 'sqMeter' to the variable. Just incidentally wiping out the value of surface that was passed into the function. __________________ An optimist sees the glass as half full. A pessimist sees the glass as half empty. A realist drinks it no matter how much there is.
 11-09-2012, 06:58 AM PM User | #4 axel22 New to the CF scene   Join Date: Oct 2012 Posts: 6 Thanks: 2 Thanked 0 Times in 0 Posts the whole point is to find HEIGHT by the representing values of surface and height from being passed from (surface) sqFt to sqMeters and (weight) passed from lbs to kgs using the Height formula which will use the previous functions to calculate height into inches.
11-09-2012, 08:15 AM   PM User | #5
Philip M
Supreme Master coder!

Join Date: Jun 2002
Location: London, England
Posts: 17,478
Thanks: 200
Thanked 2,470 Times in 2,448 Posts
Quote:
 Originally Posted by axel22 the whole point is to find HEIGHT by the representing values of surface and height from being passed from (surface) sqFt to sqMeters and (weight) passed from lbs to kgs using the Height formula which will use the previous functions to calculate height into inches.
Clear as mud! Can you explain further and/or give an example? And be clearer as to what your question actually is?

You do not call your functions function SqFeetToSqMeters(sqFeet)
and so on anywhere.
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.

Last edited by Philip M; 11-09-2012 at 08:19 AM..

 11-09-2012, 08:19 AM PM User | #6 Old Pedant Supreme Master coder!     Join Date: Feb 2009 Posts: 24,952 Thanks: 75 Thanked 4,307 Times in 4,274 Posts Yes? And you *HAVE* a function there that will convert square feet to square meters: Code: ```function SqFeetToSqMeters(sqFeet) { var sqMeters; sqMeters = sqFeet/10.764; return sqMeters; }``` But you never use it. Instead, you just change surface from a number into a string. __________________ An optimist sees the glass as half full. A pessimist sees the glass as half empty. A realist drinks it no matter how much there is.
 11-09-2012, 08:24 AM PM User | #7 Old Pedant Supreme Master coder!     Join Date: Feb 2009 Posts: 24,952 Thanks: 75 Thanked 4,307 Times in 4,274 Posts Most of the code looks right. It's just these two lines that are total hash: Code: ``` var surface = 'sqMeter'; var weight = 'kg';``` What you want, instead is Code: ``` surface = someConversoinOf( surface ); weight = someConversionOf( weight );``` You get to figure out what someConversionOf needs to be. Notice that I did *NOT* use var there. That *IS* important. __________________ An optimist sees the glass as half full. A pessimist sees the glass as half empty. A realist drinks it no matter how much there is.
 11-09-2012, 08:55 AM PM User | #8 Philip M Supreme Master coder!     Join Date: Jun 2002 Location: London, England Posts: 17,478 Thanks: 200 Thanked 2,470 Times in 2,448 Posts I now find that the Mostella formula calculates body surface area from height and weight for medication doses. But the OP's script seems to calculate the subject's height from his weight and body surface area. That can't be right. The formula is BSA (m²) = ( [Height(cm) x Weight(kg) ]/ 3600 )½ e.g. BSA = SQRT( (cm*kg)/3600 ) or in inches and pounds: BSA (m²) = ( [Height(in) x Weight(lbs) ]/ 3131 )½ Given that the data can be input as Metric or Imperial I don't see the point of converting the units. Note. My doctor tells me that I am exactly the correct weight - for a man 2.4 metres tall. __________________ All the code given in this post has been tested and is intended to address the question asked. Unless stated otherwise it is not just a demonstration. Last edited by Philip M; 11-09-2012 at 09:05 AM..
11-09-2012, 10:02 PM   PM User | #9
Old Pedant
Supreme Master coder!

Join Date: Feb 2009
Posts: 24,952
Thanks: 75
Thanked 4,307 Times in 4,274 Posts
Quote:
 Originally Posted by Philip M Note. My doctor tells me that I am exactly the correct weight - for a man 2.4 metres tall.
LOL! Boy, do I know that story! I'm not quite that bad, but close. (Would you believe we took a week long trip to Hawaii and I *lost* 8 pounds during the trip? And haven't gained it back. Woo hoo!)

(But I thought you were a doctor? Are you telling yourself that?)
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.

11-10-2012, 08:24 AM   PM User | #10
Philip M
Supreme Master coder!

Join Date: Jun 2002
Location: London, England
Posts: 17,478
Thanks: 200
Thanked 2,470 Times in 2,448 Posts
Quote:
 Originally Posted by Old Pedant LOL! Boy, do I know that story! I'm not quite that bad, but close. (Would you believe we took a week long trip to Hawaii and I *lost* 8 pounds during the trip? And haven't gained it back. Woo hoo!) (But I thought you were a doctor? Are you telling yourself that?)
What gave you that idea? My formal qualifications are in law and accountancy, but I claim expertise in logistics and (some) computing also.
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.

 11-10-2012, 09:26 PM PM User | #11 Old Pedant Supreme Master coder!     Join Date: Feb 2009 Posts: 24,952 Thanks: 75 Thanked 4,307 Times in 4,274 Posts Huh...I thought I looked up your location with Google once upon a time and street view showed it to be a physicians office. Was over a year ago, so I don't remember the details or where I found the address. Likely was a bogus address and/or a shared office or some such? __________________ An optimist sees the glass as half full. A pessimist sees the glass as half empty. A realist drinks it no matter how much there is.
11-10-2012, 10:00 PM   PM User | #12
Philip M
Supreme Master coder!

Join Date: Jun 2002
Location: London, England
Posts: 17,478
Thanks: 200
Thanked 2,470 Times in 2,448 Posts
Quote:
 Originally Posted by Old Pedant Huh...I thought I looked up your location with Google once upon a time and street view showed it to be a physicians office. Was over a year ago, so I don't remember the details or where I found the address. Likely was a bogus address and/or a shared office or some such?

You were thinking perhaps of

Kilmeny Group Medical Practice
Kilmeny Surgery
Ingrow
Keighley
BD21 1LA

That is not me!
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.

 11-11-2012, 12:25 AM PM User | #13 axel22 New to the CF scene   Join Date: Oct 2012 Posts: 6 Thanks: 2 Thanked 0 Times in 0 Posts is that Math.pow() function even being used correctly?
11-11-2012, 11:19 PM   PM User | #14
Old Pedant
Supreme Master coder!

Join Date: Feb 2009
Posts: 24,952
Thanks: 75
Thanked 4,307 Times in 4,274 Posts
Quote:
 Originally Posted by axel22 is that Math.pow() function even being used correctly?
If you mean in this code:
Code:
` Math.pow(surface, 2)`
then sure. That's fine. (It's also slower than simply doing `surface * surface` but that's a detail.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.

 11-11-2012, 11:20 PM PM User | #15 Old Pedant Supreme Master coder!     Join Date: Feb 2009 Posts: 24,952 Thanks: 75 Thanked 4,307 Times in 4,274 Posts Philip: Yes! That's the one. Been so long ago I don't remember even where I got that from. __________________ An optimist sees the glass as half full. A pessimist sees the glass as half empty. A realist drinks it no matter how much there is.

 Bookmarks

 Thread Tools Rate This Thread Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home :: Client side development     JavaScript programming         DOM and JSON scripting         Ajax and Design         JavaScript frameworks         Post a JavaScript     HTML & CSS     XML     Flash & ActionScript         Adobe Flex     Graphics and Multimedia discussions     General web building         Site reviews         Building for mobile devices :: Server side development     Apache configuration     Perl/ CGI     PHP         Post a PHP snippet     MySQL         Other Databases     Ruby & Ruby On Rails     ASP     ASP.NET     Java and JSP     Other server side languages/ issues         ColdFusion         Python :: Computing & Sciences     Computer Programming     Computer/PC discussions     Geek News and Humour Web Projects and Services Marketplace     Web Projects         Small projects (quick fixes and changes)         Medium projects (new script, new features, etc)         Large Projects (new web application, complex features etc)         Unknown sized projects (request quote)         Vacant job positions         Looking for work/ for hire         Project collaboration/ partnership         Paid work offers and requests (Now CLOSED)     Career, job, and business ideas or advice     Domains, Sites, and Designs for sale         Domains for sale         Websites for sale         Design templates and graphics for sale :: Other forums     Member Offers     Forum feedback and announcements

All times are GMT +1. The time now is 05:03 AM.