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 : Explain Base type Base type : The kind

    Base type: The kind of items that might be stored in an array - the arrays defined type. For example, in     int[] numbers; the base type

  • Q : Use Finite-State Space Abstractions Use

    Use Finite-State Space Abstractions: In order to successfully apply explicit-state model checking, defects must be detectable in a sufficiently small state space. This can be achieved either by means of heuristics that constrain the way the state spac

  • Q : Introduction to Programming for

    The purpose of this assignment is to get you started with C++ programming. You'll develop simple programs (with input and output) to solve simple mathematical and engineering problems. 1. Write a program to compute the area A of an

  • Q : What are Logical operators Logical

    Logical operators: The operators, like &&, ||, &, | and ^ which take two Boolean operands and generate a Boolean outcome. Employed as part of a Boolean expression, frequently in the condition of the control structure.

  • Q : What is Avoid Redundancy Avoid

    Avoid Redundancy: While not every form of redundancy is as bad from a verification perspective as it is from a maintenance point of view, behavioral redundancy to re-create (local) state can impose problems because the model checker does not distingui

  • Q : Define Continuous simulation Continuous

    Continuous simulation: In a continuous simulation, the time ticks past at a regular rate which is applicable to the specific simulation scenario. At each and every tick, all the objects in the simulation are informed of the passage of time and updated

  • Q : Is a XML replacing HTML Is a XML

    Is a XML replacing HTML?

  • Q : What does compatibility testing include

    What does compatibility testing include and who will perform the testing?

  • Q : Different compatibility types when

    What are the different compatibility types when creating a COM COMPONENT?

  • Q : Explain the term Web Services

    Explain the term Web Services Description Language.

©TutorsGlobe All rights reserved 2022-2023.