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 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 : What is Virtual desktop Virtual desktop

    Virtual desktop: The name employed to explain a user's graphical working area in a window manager. The name arises in the early days of graphical user interfaces whenever it was thought that such would lead to `paperless offices'. This was anticipated

  • Q : What is Application programming

    Application programming interface (API): It is a set of definitions that you can make use of it in writing programs. In the perspective of Java, these are the classes, packages, and interfaces which can be utilized to build complex ap

  • Q : Illustrations of XML DTDs or schemas

    Give some illustrations of XML DTDs or schemas which you have?

  • Q : Explai phases of software development

    Define the difference between phases of software development or software life cycle?

  • Q : Define the term Catching exceptions

    Catching exceptions: Exceptions are caught in the catch clause of the try statement. Catching an exception provides the program a chance to recover from the trouble or attempt a repair for whatsoever caused it.

  • Q : Properties exposed through ActiveX

    Write down the properties exposed through ActiveX controls?

  • Q : Create a BottomUpTwoThreeFourTree class

    You will need to create a BottomUpTwoThreeFourTree class, with a BottomUpTwoThreeTreeFourTree constructor which keeps no parameters. BottomUpTwoThreeTreeFourTree will require an insert(int x) method, which will insert the value 

  • Q : Print the factors of each perfect number

    An integer number is said to be a perfect number if its factors, including 1 (but not the number itself), sum to be the number. For example, 6 is a perfect number because 6 = 1+ 2+ 3. Write a function perfect that determines if parameter number is a perfect number. Us

  • Q : Computer science 1. Here is a short

    1. Here is a short program. It prints out the value of a variable "x". Ernie and Bert disagree about what will be printed: Ernie says, the value gets changed in "changeX" so it will print "7", and Bert says, no, when the function exits the changes get reversed and the value goes back to "5". Explain

©TutorsGlobe All rights reserved 2022-2023.