## NEED MORE HELP WITH UNIT COVERSION SOFTWARE

New to FreeBASIC? Post your questions here.
nosman
Posts: 15
Joined: Aug 04, 2010 17:06

### NEED MORE HELP WITH UNIT COVERSION SOFTWARE

I have made a unit conversion software that can right now only do grams ounces and pounds. i have accomplised the grams part but now i cant seem to get the oz part. what am i doing wrong?

Code: Select all

`sub ozdim as single grams,ozzdim as integer poundsprint"you can convert ounces to grams and pounds here"input"how many ounces" ; ozzgrams = ozz / 28.3495if ozz < 16.0 then pounds = 0elsepounds = fix (ozz * 16.0) * 1ozz = ozz - (pounds * 16)endifprint ozz;"ounces are equal to"print grams;"grams"print pounds; "pounds"end subsleep`
j_milton
Posts: 458
Joined: Feb 11, 2010 17:35
When you get stuck on a thing like this something to try is to forget for a while that you have a computer.
Solve the problem manually; pen, paper, and calculator. Do this 2 or 3 times until you get correct answers and find the best method. Then write down step by step, in English (or whatever your native language is) the method that you used.
Then take those instructions and "translate" them into BASIC
nobozoz
Posts: 238
Joined: Nov 17, 2005 6:24
Location: Chino Hills, CA, USA

Code: Select all

`sub oz()#Define float Singledim as float grams,ozzdim as float pounds_decType lb_oz   lb_ As float   oz_ As floatEnd TypeDim pounds_oz As lb_ozConst _lb2kg = 0.453592370   '1.0 lb = 0.453592370 kg (EXACTLY)Const _lb2oz = 16                  'EXACTLYConst _lb2gm = _lb2kg*1000Print "Convert ounces to grams, decimal pounds and pounds with fractional ounces."Input "How many ounces " ; ozzgrams = ozz/_lb2oz*_lb2gmpounds_dec = ozz/_lb2ozpounds_oz.lb_ = fix(pounds_dec)pounds_oz.oz_ = (pounds_dec - pounds_oz.lb_)*_lb2ozprint Using "########.### ounces    are equal to";ozzprint Using "########.### grams";gramsprint Using "########.### pounds";pounds_decprint Using "########     pounds ####.# ounces ";pounds_oz.lb_;pounds_oz.oz_end SubozSleep`