Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / *sigh* this may be easy but need some advice on a problem (school late assignment)

Author
Message
Lover of games
20
Years of Service
User Offline
Joined: 17th Apr 2005
Location:
Posted: 21st Dec 2010 22:05
Well, the problem is that i have to enter the number of centimeters and output the value in inches, then get how many yards, feet and inches in the inches gotten from the centimeters;

here is my attempt to find the inches from the centimeters.



now the book says that 312 centimeters = 123 inches, but when i put the 312 i get 26...weird!!

"Originally I was going to have a BS on it but you know how that would be. I can't walk around with the letters BS on me." More or less a qoute by Syndrome from Jack, Jack, attack
Jeku
Moderator
21
Years of Service
User Offline
Joined: 4th Jul 2003
Location: Vancouver, British Columbia, Canada
Posted: 21st Dec 2010 23:03 Edited at: 21st Dec 2010 23:05
Quote: "now the book says that 312 centimeters = 123 inches, but when i put the 312 i get 26...weird!!"


Your logic is wrong. If you notice your INCHES = 12, so you're doing 312 / 12. You should make a variable called CENTIMETERS_PER_INCH or something like that.

EDIT:

Using your existing variables you should go:



That should give you roughly 123.


Senior Web Developer - Nokia
Lover of games
20
Years of Service
User Offline
Joined: 17th Apr 2005
Location:
Posted: 23rd Dec 2010 14:13
thanks, did that and it semi worked got 12 for some reason

"Originally I was going to have a BS on it but you know how that would be. I can't walk around with the letters BS on me." More or less a qoute by Syndrome from Jack, Jack, attack
Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 24th Dec 2010 06:43
A good way to keep track of units is dimensional analysis. (if you're not familiar, it's basically like using units as coefficients).

x in = 312cm/(2.54 cm/in)
y ft = x in/(12 in/ft)
z yd = y ft/(3 ft/yd)

just sayin'

Login to post a reply

Server time is: 2025-05-30 23:55:23
Your offset time is: 2025-05-30 23:55:23