EasyManua.ls Logo

AMSTRAD CPC464 - 4.4 Getting going; 4.5 Conditional and logical statements

AMSTRAD CPC464
249 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Here comes a brief program to demonstrate these operators, based on subject very dear to our
hearts. If you are not already looking at the switch on screen message:
Amstrad 64k Microcomputer (v1)
c 1984 Amstrad Consumer Electronics
and Locomotive Software Ltd.
BASIC 1.0
Ready
. . ..then press the [CTRL] [SHIFT] and [ESC] keys, holding them down simultaneously, and the
computer will reset to the above message. Now proceed and type in the following (editing
instructions are given in 1.2.7):
10 INPUT "WHAT IS YOUR SALARY";SALARY
20 IF SALARY < 10000 THEN GOT0 30 ELSE 40
30 PRINT "ASK FOR A PAY RISE":END
40 PRINT "ASK FOR A BIGGER CAR"
Run this small program by typing:
RUN
and the obligatory [ENTER]. The computer asks you a question:
WHAT IS YOUR SALARY?
(Note how the computer automatically adds the question mark when it wants you to respond with
an input of data). Answer the question using only numbers not letters, currency signs or commas,
and enter your answer with the [ENTER] key.
Add line 5 below by simply typing after the end of the above operation, when the Ready prompt
reappears:
5 CLS
RUN again to wipe the screen. If your first answer was less than 10000, make this reply more than
10000, and you will see the difference. Now extend the original program by adding line 50 below:
5 CLS
10 INPUT "WHAT IS YOUR SALARY";SALARY
20 IF SALARY < 10000 THEN GOT0 30 ELSE 40
30 PRINT "ASK FOR A PAY RISE": END
40 PRINT "ASK FOR A BIGGER CAR"
50 IF SALARY >30000 THEN PRINT "and
get a good accountant"
run
The END at line 30 stops the program and returns to the prompt. Since theres no end on line 40, the
program proceeds to see if the SALARY variable is greater than 30000 - in which case the program
responds with yet more sound advice!

Table of Contents

Other manuals for AMSTRAD CPC464

Related product manuals