tags:

views:

79

answers:

2

I'm trying to build a "simple" web app that calculates either a male or females body fat % based on the U.S. Navy's circumference formula. I have the majority of the app completed at this point. However, I cannot figure out why the way I've setup the formula below won't work. Two of the values are underlined in red in my .cs file.

My Formula:

TBBodyFat.Text = Convert.ToString(495 / (1.0324-.19077(Math.Log(Convert.ToDouble(TBWaist.Text)-Convert.ToDouble(TBNeck.Text)))+.15456(Math.Log(Convert.ToDouble(TBHeight.Text)))));  

Original Example:

%Fat=495/(1.0324-.19077(log(abdomen-neck))+.15456(log(height)))-450       

Pop-Up for the two underlined values (.19077 and .15456):

struct System.Double  
Represents a double-precision floating-point number.

Error:  
Method name expected  
+6  A: 
    TBBodyFat.Text = Convert.ToString(495 / (1.0324-.19077*
(Math.Log(Convert.ToDouble(TBWaist.Text)-Convert.ToDouble(TBNeck.Text)))+.15456*
(Math.Log(Convert.ToDouble(TBHeight.Text)))));

C# (not any programming language I've yet encountered) does not take adjacency of numbers to mean multiplication!

Will A
in less than 55 seconds! That's quick ;-)
Abel
8-) - I try! Someone will no doubt come up with a language that does respect algebraic conventions. :)
Will A
It's always the obvious things that end up being the culprit...that was it and it now works. Thanks for the help!!
Chris
My pleasure - enjoy your coding!
Will A
+4  A: 

Well you need to use "*" for multiplication. Plus I'm not sure whether C# allows ".123" style numeric literals without leading 0.

Try:

 TBBodyFat.Text =
      Convert.ToString(495/
         (1.0324-0.19077*(Math.Log(Convert.ToDouble(TBWaist.Text)-Convert.ToDouble(TBNeck.Text)))+0.15456*(Math.Log(Convert.ToDouble(TBHeight.Text)))));
Mau
*"whether C# allows ".123" style numerl literals "* >> they do ;-)
Abel
@Abel: thanks :-)
Mau