--%>

Data structure appears in a COBOL program

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.

E

Expert

Verified

we will  declare one variable as “A “………. 01 A PIC 99.

PROCEDURE-DIVISION.
PROGRAM-BEGIN.
PERFORM MAIN-PROGRAM.
PROGRAM-END.
STOP RUN.

(i) MAIN- PROGRAM.
 PERFORM CHECK-DATA VARYING A FROM 1 BY 1 UNTIL A <= NUMBER-OF-CURRENCIES.

CHECK-DATA.
       IF CURRENCY-CODE(A) = “PLN”
               MOVE 4.637 TO CURRENCY-RATE(A)
      
               MOVE 1 TO SUCCESS-INDICATOR
               GO TO  PROGRAM-END

         ELSE
                 MOVE 0 TO SUCCESS-INDICATOR.

(ii) we will  declare one variable as “WS-RATE “………. 01 WS-RATE PIC 999V99.

MAIN- PROGRAM.
 PERFORM CHECK-DATA VARYING A FROM 1 BY 1 UNTIL A <= NUMBER-OF-CURRENCIES.

CHECK-DATA.
       IF CURRENCY-CODE(A) = “EUR”
               COMPUTE  WS-RATE ROUNDED = AMOUNT-REQUIRED.
      
               MOVE 1 TO SUCCESS-INDICATOR
               GO TO  PROGRAM-END

         ELSE
                 MOVE 0 TO  SUCCESS-INDICATOR.

(iii) IF NUMBER-OF-CURRENCIES < 50

                       ADD 1 TO  NUMBER-OF-CURRENCIES
                       MOVE “KWD”  TO CURRENCY-CODE(NUMBER-OF-CURRENCIES)
                       MOVE 0.4488 TO CURRENCY-RATE(NUMBER-OF-CURRENCIES)
                       MOVE 1 TO  SUCCESS-INDICATOR
            
               ELSE
                       MOVE 0 TO  SUCCESS-INDICATOR.

   Related Questions in Programming Languages

  • Q : Define Loop variable Loop variable : A

    Loop variable: A variable employed to control the operation of a loop, like a for loop. Usually, a loop variable will be provided an initial value and it is then incremented after each and every iteration till it passes or reaches a terminating value.

  • Q : Define Property Specifications Property

    Property Specifications: Users can specify assertions using the assert(expr) statements. An assert statement is used to check if the property specified by the expression expr is valid within a state. If expr evaluates to 0, this implies that it is not

  • Q : Explain Assignment operator Assignment

    Assignment operator: The operator (=) employed to store the value of an expression into the variable, for example: Variable = expression; The right-hand

  • Q : Define the term RGB Color Model Define

    Define the term RGB Color Model: It is a color model based on representing a color as three components: green, red, and blue.

  • Q : Program for Linux operating system that

    Write a program for Linux operating system that uses Posix threads to sort a large array.  Specifically, you should write a program to generate random numbers. Then create at least two threads, each of which sorts a portion of the array. After the thr

  • Q : Microsoft Access I have attached a

    I have attached a database and a PDF with 5 questions. I need the 5 questions answered with 5 queries in the database. Question 3 needs a crosstab query. All the questions require the proper join.

  • Q : What is sticky bit Explain the sticky

    Explain the sticky bit?

  • Q : What is Process Process : It is an

    Process: It is an individual thread-of-control to which an execution time slice is assigned by the operating system.

  • Q : What are good examples of XHTML

    What are the good examples of XHTML elements along with contents?

  • Q : Define the term Inheritance Inheritance

    Inheritance: It is a feature of object-oriented programming languages in which a sub-type inherits methods and variables from its super-type. The Inheritance is most generally employed as a synonym for class inheritance {class!inheritance}, however in