Lesson #4 Sales Commissions - Radio Shack TRS-80 Model 100 Basic Manual

Basic language lab
Hide thumbs Also See for TRS-80 Model 100:
Table of Contents

Advertisement

Lesson #4 Sales Commissions
It is often necessary to write programs that will do one task if a condition is true and
another if the condition is false. This is called branching. In this lesson you will learn
why this concept is important and how to implement branching in your programs.
Experiment #1 Sales Commissions
A salesman is to receive a flat rate commission of 15% of his total sales. However, if
the total sales is over $2000, then he will receive an additional 20% of the amount
over $2000.
The formulas are as follows:
Commission
=
.15
*
sales if sales are less than 2000
Commission
=
.15
*
sales
+
.20
*
(sales - 2000) if sales are over 2000
Clear memory with the NEW command and type the following program:
1121 INPUT "AMOUNT OF SALES"; ST
ZI2I CM
=
ST
*
.15
3121 IF ST
>
2121121121 THEN CM
=
CM
+
.20
*
(ST - 2121121121)
4121 PRINT "COMMISSION IS";CM
Execute this program.
The program begins by asking you to enter the amount of sales. Type:
1121121121
~
to compute the commission on one thousand dollars sales. Note that a dollar sign is
not entered. The computer will respond with the message
COMMISSION IS 15121
indicating a commission of $150.
Since the sales were less than $2000, the commission is a straight fIfteen percent.
RUN the program again and this time when you are asked to enter the amount of
sales, type:
3121121121
~
to compute the commission on three thousand dollars sales. The computer will respond
with the message:
COMMISSION IS 85121
indicating a commission of $650. Since the sales exceed $2000, the commission will
be 15% of $3000 plus 20% of $1000 (the amount exceeding $2000).
Try running the program using your own sales data and confIrm that the program
computes the commission properly.
45

Advertisement

Table of Contents
loading

Table of Contents