Archive for May 27, 2014

Mileage Converter

Howdy folks! Recently I started to re-dable (now that’s a funny word, if in fact it is a real word) with BASIC programming. Programming in BASIC, for me, goes all the way back to being twelve to fourteen years old, somewhere in the early 80’s. That’s when the Apple ][+ ruled the personal computer world!

I found an App for iOS, Misoft Basic!, that purported to be an Apple staff favourite for its nostalgic feel, much like the old AppleSoft BASIC of the day. My father thought it would be fun to try some programming again and suggested we work together on a mileage converter. I agreed but went a little overboard and wrote the whole thing one afternoon. So, after cutting my dad out of the fun, he is taking it a step further and is giving it a graphical interface, as opposed to my purely text offering.

I am including the code to what I’ve written so far if you’d like to try it out. Be aware that not all versions of BASIC use exactly the same syntax or commands but if your willing to give this a go, you probably already know that.

10 Rem Convert l/100 to us & imp and back
12 REM by Wayne Goldsmith
13 CLS
15 PRINT “*******************************”
20 PRINT “Welcome to the Multi-Mileage Converter.”
30 PRINT “*******************************”
35 PRINT
40 PRINT ” 1) L/100 to Imperial MPG”
45 PRINT ” 2) Imperial MPG to L/100″
50 PRINT ” 3) L/100 to US MPG”
55 PRINT ” 4) US MPG to L/100″
57 PRINT ” 5) End”
60 PRINT
65 INPUT “Pleas enter you choice… “;c
70 IF c=1 THEN
GOSUB 135
ELSE
IF c=2 THEN
GOSUB 180
ELSE
IF c=3 THEN
GOSUB 250
ELSE
IF c=4 THEN
GOSUB 320
ELSE
IF c=5 THEN
GOSUB 400
END IF
END IF
END IF
END IF
END IF

GOTO 13

135 REM l/100 to imp mpg
136 PRINT
140 INPUT “Please enter your L/100 to IMP MPG you would like to convert. “;l
150 mpg=282.48/l
155 PRINT
157 PRINT
160 PRINT “Your L/100 figure works out to “mpg” Miles Per Gallon!”
165 PRINT
166 PRINT
168 GOSUB 450
170 RETURN

180 REM imp mpg to l/100
181 PRINT
190 INPUT “Please enter the Imperial MPG you would like to convert to L/100… “;mpg
200 l=282.48/mpg
210 PRINT
220 PRINT
230 PRINT “Your Imperial MPG figure works out to “l “L/100. ”
235 PRINT
236 PRINT
238 GOSUB 450
240 RETURN

250 REM l/100 to us mpg
251 PRINT
260 INPUT “Please enter the L/100 figure you would like to convert to US MPG… “;l
270 mpg=235.2/l
280 PRINT
290 PRINT
300 PRINT “Your L/100 figure works out to “mpg” US Miles Per Gallon!”
305 PRINT
306 PRINT
308 GOSUB 450
310 RETURN

320 REM US MPG to L/100
321 PRINT
330 INPUT “Please enter the US MPG figure you would like to convert to L/100…. “;mpg
340 l=235.2/mpg
350 PRINT
360 PRINT
370 PRINT “Your US MPG figure works out to “l “L/100.”
375 PRINT
376 PRINT
378 GOSUB 450
380 RETURN

390 GOTO 20

400 PRINT
410 PRINT ” Thank you for using The Multi-Mileage Converter.”
420 END

450 INPUT “Press ‘C’ to continue, or ‘Q’ to quit.”;d$
460 IF d$=”c” THEN
RETURN
ELSE
IF d$=”q” THEN
GOTO 400
ELSE
GOTO 450
ENDIF
ENDIF