$ ADA/LIST STRING_IO 1 2 -- STRING_IO a sample to demonstrate input and output of 3 -- string type data, and using the if-then-else structure 4 -- 5 -- The names of four transactions are defined as an Ada strings. 6 -- i.e. a user chosen set of english words that can be input, 7 -- output, and recognized. This is an alternative to enumeration types. 8 9 -- BANK_TRANSACTIONS can be OPEN CLOSE DEPOSIT WITHDRAW 10 11 with TEXT_IO ; use TEXT_IO ; 12 13 procedure STRING_IO is 14 15 subtype TRANSACTIONS is STRING ( 1 .. 8 ) ; 16 TRANSACTION : TRANSACTIONS ; 17 18 begin 19 20 loop 21 22 PUT_LINE ( " ENTER TRANSACTION. " ) ; 23 GET ( TRANSACTION ) ; 24 PUT ( TRANSACTION ) ; 25 PUT_LINE ( " transaction being processed" ) ; 26 27 if TRANSACTION = "OPEN " then 28 PUT_LINE ( " opening " ) ; 29 elsif TRANSACTION = "CLOSE " then 30 PUT_LINE ( " closing " ) ; 31 elsif TRANSACTION = "DEPOSIT " then 32 PUT_LINE ( " depositing " ) ; 33 elsif TRANSACTION = "WITHDRAW" then 34 PUT_LINE ( " withdrawing " ) ; 35 else 36 PUT_LINE ( " not a transaction " ) ; 37 end if ; 38 39 end loop ; 40 41 end STRING_IO ; $ ACS LINK STRING_IO $ RUN STRING_IO -- instructors notes: ENTER TRANSACTION. <- line 22 OPEN <- I typed OPEN and 4 spaces OPEN transaction being processed and opening <- line 28 ENTER TRANSACTION. <- line 22 DEPOSIT <- I typed DEPOSIT and 1 space DEPOSIT transaction being processed <- line 25 depositing <- line 32 ENTER TRANSACTION. <- line 22 open <- I typed open and 4 spaces open transaction being processed <- line 25 not a transaction <- line 36