EasyManuals Logo

Sinclair QL User Manual

Sinclair QL
422 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #107 background imageLoading...
Page #107 background image
Pro@ram
Procedures
and
Functions
370
DEFine
PROCedure
compute(dish,
total)
380
LET
total
= 0
390
FORk=1to3
400
LET
total
=
total
+
dish(k)*price(k)
410
END
FOR
k
420
END
DEFine
The walter also passes information
to
the cook who simply prints the number required
for each menu item.
430
DEFine
PROCedure
cooUdish)
440
FOR
c = 1
TO
3
450
PRINT I
dish(C)
I
item$(c)
I
460
END
FOR
c
470
END
DEFine
Again, the
array,
dish
in
the procedure cook
is
local.
It
receives the information which
the procedure uses
in
its
PRINT statement
The complete program
is
listed below.
100
REMark
Procedures
110
RESTORE
490
120
DIM
item$<3,n,
price(3),
dish(3)
130
REMa
rk
***
PROGRAM
***
140
LET
tip
=
0.1
150
set
up
160
choose
dish
170
waiter
dish,
bi
II
180
LET
bill
=
bill
+ t i
p*b
i
II
190
PRINT
"Total
cost
is
£";
bill
200
REMark
***
PROCEDURE
DEFINITIONS
***
210
DEFi
ne
PROCedure
set
up
220
FOR
k =1
TO
3 -
230
READ
item$(k)
240
READ
price(k)
250
END
FOR
k
260
END
DEFine
270
DEFine
PROCedure
choose(dish)
280
FOR
pic
k =1
TO
6
290
LET
number
=RND(1
TO
3)
300
LET
dish(number)
=
dish(number)
+ 1
310
END
FOR
pi
ck
320
ENO
DEFine
330
DEFine
PROCedure
waiter(dish,
cost)
340
compute
dish,cost
350
cook
di
sh
360
END
DEFi
ne
370
DEFine
PROCedure
compute(dish,
total)
380
LET
tota
l = 0
390
FOR
k =1
TO
3
400
LET
total
=
total
+
dish(k)*price(k)
410
END
FOR
k
420
END
DEFine
430
DEFine
PROCedure
cook(dish)
440
FOR
c = 1
TO
3
450
PRINT I
dish(c)
I
item$(C)
460
END
FOR
c
470
END
DEFine
480
REMark
***
PROGRAM
DATA
***
490
DATA
"Prawns",
3.5,
"Chicken",2.8,"Special",3.3
The output depends on the random choice of dishes but the following choice Illustrates Output
the pattern, and gives a sample of output.
3 Prawns
1
Chicken
2
Special
Total
cost
is
£20.40
12/84
91

Other manuals for Sinclair QL

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Sinclair QL and is the answer not in the manual?

Sinclair QL Specifications

General IconGeneral
ProcessorMotorola 68008
Clock Speed7.5 MHz
RAM128 KB (expandable to 640 KB)
ROM48 KB
Operating SystemSinclair QDOS
Release Year1984
StorageMicrodrive tape loop
Graphics256x256 pixels, 8 colors
PortsRS-232, ROM cartridge
SoundBeeper (internal speaker)

Related product manuals