The following data structure appears in a COBOL program used by a bureau de change:
01 AUXILAIRY-ITEMS.
05 AMOUNT-REQUIRED PIC999V99.
05 SUCCESS-INDICATOR PIC 9.
88 SUCCESS VALUE 1.
01 CURRENCY-TABLE.
05 CURRENCY-RATE OCCURS 50 TIMES.
10 CURRENCY-CODE PIC AAA.
10 CURRENCY-RATE PIC 9(5)V9999.
05 NUMBER-OF-CURRENCIES PIC 99.
Various foreign currencies are given ISO-standard three-letter codes (CURRENCY-CODE) and these are stored in the table (array) CURRENCY-TABLE together with the corresponding exchange rate (CURRENCY-RATE). The exchange rate is expressed as the amount of the foreign currency purchased for one pound (GBP).
The currencies are stored in elements 1 to NUMBER-OF-CURRENCIES of the table.
Assuming that all the relevant data items have been correctly initialised, write fragments of COBOL for each of the following tasks. In each case set the value of SUCCESS-INDICATOR such that the condition-name SUCCESS has the appropriate value after the operation.
i) Update the exchange rate for "PLN" TO 4.637.
ii) Look up the currency rate for "EUR" and calculate the (rounded) amount of this currency that corresponds to the value of AMOUNT-REQUIRED.
iii) Add a new currency to the table with the value "KWD" and the exchange rate 0.4488.