Page 1 of 1

[SOLVED] Need a little help with my equation....

Posted: Sat Mar 28, 2009 2:49 pm
by Keevu
need to get the rmr

Im getting the wrong answer when I run the program.
If I input the numbers found in thie image, http://tinyrealm.com/~efa/cisc2305/pics/rmr.jpg
I get a different answer on my program than the other program in the image.

********************************
* RMR = (9.99w + 6.25s) - 4.92a + 166g

* w = weight in kilograms; if you know your weight in pounds,
divide by 2.2 to get your weight in kilograms

* s = height in centimeters; if you know your height in inches,
multiply by 2.54 to get your height in centimeters

* a = age in years

* g = gender = 1 for males, 0 for females
********************************

//my equation so far
((((9.99 * wk) + (6.25 * hc)) - (4.92 * ageyears) + gender)) //wk is weight in kilograms aka w
//hc is height in centimeters aka s
//height in Centimeters so far
hc = (float)(((heightfeet * 12) * 2.54) + (heightinch * 2.54));

//weight in Kilograms so far
wk = (float)((weightpounds) / (2.2));


source code for visual c#
lab6.zip
this is entire program
(61.85 KiB) Downloaded 64 times

Re: Need a little help with my equation....

Posted: Sat Mar 28, 2009 2:54 pm
by ismetteren
either i am lacking math skills(or actually, i know i am) or you havent told what the actual problem is.

Re: Need a little help with my equation....

Posted: Sat Mar 28, 2009 2:56 pm
by Keevu
ismetteren wrote:either i am lacking math skills(or actually, i know i am) or you havent told what the actual problem is.
Im getting the wrong answer if I input the same numbers in this image http://tinyrealm.com/~efa/cisc2305/pics/rmr.jpg

I cant figure out where I went wrong I looked over it many times.

Re: Need a little help with my equation....

Posted: Sat Mar 28, 2009 5:19 pm
by Scoody
Quick debug show that heightinch is 5, when it should be 9, which leads to:

Code: Select all

heightinch = float.Parse(textBox1.Text);
Which should be textBox5.

On a side note, IMHO, you're doing way too much in a single statement. Try splitting them more up, easier to see what's going on.
Make a function that converts feet to cm, and same for inches to cm. And shouldn't you be converting the "result" variable instead of calculating it again? (if it isn't a debug-leftover.. :))

Re: Need a little help with my equation....

Posted: Sun Mar 29, 2009 11:27 pm
by Keevu

Code: Select all

heightinch = float.Parse(textBox1.Text);
Which should be textBox5.
:lol: it works I cant believe i didnt see that.