Section 4: Programming 154

Sample Case: Repeating and Stopping

Assume that you get a 15% discount (i.e., you pay 85%) on the following purchases:
  Quantity Price of Each  
 
  5  
  $2.00  
 
 
  7  
  4.00  
 
 
  8  
  5.00  
 
 
  22  
  6.00  
 
Create a program at the top of memory to display the cumulative cost.
Only two unfamiliar operations (GTO and R/S) are needed. They are summarized in Figure 4-3.
Method. After clearing the stack once at the start, let the program stop to accept data and to display any previous accumulation (zero, at first). Then key in:
Quantity ENTER  Price R/S
Have the program then calculate the discounted cost (5 × 2 × .85, the first time), adding the cost to the previously accumulated total. Repeat this for the second, third, and fourth pairs which are to be entered after the respective stops. The flowchart (p. 55), shows the process.
Writing the Program
1. To key in the program set the mode switch to W/PRGM.
2. Press fPRGM to clear program memory.
3. Key in the program.
Again, for now, if you make a mistake, clear memory and start over.
Press     Comment
f      Clear the stack.
STK   
LBL      Identify place to start repetition.
9   
R/S      Stop the calculator. During the stop key in a pair of values and press R/S to restart the program.