1

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  
1
  • Will A seems to have the solution for you, but I have to recommend that if that is your formatting and not just a result of the copy and paste then you may want to consider formatting differently to make issues such as this more evident. Possibly breaking this formula out across multiple lines may make it easier for you to debug issues later on. Then again my programming doesn't usually require much complex math so formatting it that way may be like sticking a fork into your eye for those who regularly have to deal with this type of code. Commented Aug 1, 2010 at 0:12

3 Answers 3

6
    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!

Sign up to request clarification or add additional context in comments.

4 Comments

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

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)))));

1 Comment

"whether C# allows ".123" style numerl literals " >> they do ;-)
-1

Put * while multiplying like .8*(b-200) .If you will put directly .8(b-200) it will show error that method name expected.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.