Section 11: Branching and Looping172
YES
 
 
 
 
Conditional Test
GTO 02
Instruction
Instruction
LBL 02
Instruction
 
 NO
 
 
 
Now let’s look at that tax accountant’s problem again. For persons with incomes of more than $10,000 the program should compute a tax of 22%. For persons with income of $10,000 or less the tax is 17.5%. The following program will test the amount in the X-register and compute and display the correct tax amount.
Keystrokes Display    
PRGM 
       
   
g GTO · · 
  00 REG 46    
   
g LBL 
       
   
ALPHA TAX ALPHA 
  01 LBLTTAX    
  The program name.
ALPHA INCOME? ALPHA 
  02TINCOME?    
  Prompts for income.
XEQ 
       
   
ALPHA PROMPT ALPHA 
  03 PROMPT    
  Displays prompt and halts execution so you can key in the income.
10000
  04 10000 _    
   
X Y 
  05 X<>Y    
  Amount of $10,000 put in Y-register.
g X>Y? 
  06 X>Y?    
  Conditional test. If income is greater than $10,000, does the next line in the program. If not, skips the next line.
g GTO 02
  07 GTO 02    
  Branch to LBL 02.
17.5
  08 17.5 _    
  Tax rate (income less than $10,000).
g GTO 03
  09 GTO 03    
  Branch to LBL 03.
g LBL 02
  10 LBL 02    
   
22
  11 22 _    
  Tax rate (incomes more than $10,000).
g LBL 03
  12 LBL 03    
   
g  %  
  13 %    
  Computes the tax.
g GTO · · 
  00 REG 41