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

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
Keevu
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 16
Joined: Tue Mar 24, 2009 3:53 pm

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

Post 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 63 times
Last edited by Keevu on Sun Mar 29, 2009 11:28 pm, edited 3 times in total.
User avatar
ismetteren
Chaos Rift Junior
Chaos Rift Junior
Posts: 276
Joined: Mon Jul 21, 2008 4:13 pm

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

Post by ismetteren »

either i am lacking math skills(or actually, i know i am) or you havent told what the actual problem is.
Image ImageImage Image
User avatar
Keevu
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 16
Joined: Tue Mar 24, 2009 3:53 pm

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

Post 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.
Scoody
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 65
Joined: Fri Feb 06, 2009 2:07 pm

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

Post 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.. :))
User avatar
Keevu
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 16
Joined: Tue Mar 24, 2009 3:53 pm

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

Post by Keevu »

Code: Select all

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