home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.whtech.com
/
ftp.whtech.com.tar
/
ftp.whtech.com
/
club100
/
ref
/
adder.ba
next >
Wrap
Text File
|
2006-10-19
|
3KB
|
71 lines
Title: ADDER.BA V1.0
The Model 100 series computers do not come with a built in calculator. Oh
sure, you can go into BASIC and enter commands like ?2+2 but what a drag when
you have to add up a lot of numbers, let alone provide a print out.
There's lots of lists in this world that need adding and printing, like sales,
or credit card slips, or check stubs, taxable items, etc. Most folks use a
tape calculator. They enter all the items into the calculator and print a
total. Then, they check each item against the tape. And, if they entered any
one item wrong, they do the whole process over again, just to eliminate one
error.
Programming an automatic adding machine is actually quite simple. First, you
need to enter all your numbers into a .DO file called DATA. Then enter
several numbers, and hit enter after each number. Here are some rules about
numbers that you may find interesting.
1) Do not enter dollar signs or commas
2) The letter l is not the number 1
3) The letter O is not the number 0
When you're finished, go back to the menu.
Next, go into BASIC and enter the following program.
10 'ADDER.BA Richard Hanson v1.0
20 'A public domain program, designed
30 'for the CLUB 100 online class
40 'entitled: Programming in BASIC.
50 '
60 'CLUB 100: 415-939-1246 BBS
70 '
80 MAXFILES=1
90 OPEN"DATA.DO"FORINPUTAS1
100 IFEOF(1)THENCLOSE:GOTO150
110 INPUT#1,A
120 T=T+A
130 LPRINTUSING"##,###.##";A
140 GOTO100
150 LPRINT"---------"
160 LPRINTUSING"$#,###.##";T
170 MENU
When you are finished, save the program with the command: SAVE"ADDER"
It is important that you entered the program exactly as indicated. If you
need to make changes, you may enter the command, EDIT, and hit enter. The
EDIT command places the program into your TEXT editor. Make any necessary
changes. When you are finished, hit your F8 function key to return to BASIC.
Your changes are made. Lastly, hit your F8 function key, once again, to
return to the menu.
It's time to give it a try. The ADDER.BA program assumes that you have a
printer attached to your computer, and that it is turned on. If this is not
so, the program will just sit there, and you will have to do a SHIFT BREAK to
stop the process.
ASSIGNMENT
1) Using the 01 series files in this class section, write an explanation for
each line of code in this program. Then, using REM statements, annotate
the ADDER.BA program.
2) How big of a number will this program correctly display? HINT: Place
bigger numbers in your DATA.DO file and test ADDER.BA on them.
3) Increase the PRINTUSING format string to handle larger numbers.
<EOF>