The COBOL ALTER statement

Task 3

Explain the effect of the following pictures:

05 FIELD-1 PIC Z(5)9.

05 FIELD-2 PIC £(5)9.99.

05 FIELD-3 PIC £**,***.99.

05 FIELD-4 PIC £££,££9.99DB.

05 FIELD-5 PIC ZZZZ9+.

by showing the output that will be produced if each if the following values is moved to each of the above data-items:

12345678

0.2566

-180

 

Task 4

There are many errors in the following COBOL source code. Identify the errors and rewrite the program so that it contains no errors:

IDENTIFICATION DIVISION

PROGRAMID. ERRORS-EXAMPLE.

DATA DIVISION

77 ITEM-DESC PIC X20.

77 ITEM COST PIC 999V99.

77 VAT 999V99.

77 TOTAL PIC 999V99.

PROCEDURE-DIVISION.

BILL-SEQ

MOVE 0 TO TOTAL.

         INPUT ITEM-DESC

         INPUT ITEM-COST.

INPUT-ITER.

         IF ITEM-COST = 0 GOTO INPUT-END

                  ADD ITEM-COST TO TOTAL

                  ACCEPT ITEM-DESC

                  ACCEPT ITEM-COST

                  GO TO INPUT ITER.

         VAT = 0.15 X TOTAL

         ADD VAT TO TOTAL

         DISPLAY OUTPUT TOTAL

         STOP-RUN.

BILL-END

 

Task 5

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-CURRENCIESof 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.

 

Task 6

The COBOL ALTER statement was removed from the language after early versions. Briefly explain what the ALTER statement was and discuss why you think it was removed from the language.

   Related Questions in Programming Languages

  • Q : What is an Unchecked exception

    Unchecked exception: An exception for which it is not needed to give a local try statement or to propagate through a throws clause stated in the method header. An exception which is not handled will cause program annihilation when it is thrown.

  • Q : DOT Net namespace Explain the main

    Explain the main classes given by the .NET namespace to process the XML files.

  • Q : Define Hexadecimal Hexadecimal : Number

    Hexadecimal: Number representation in hexadecimal is base 16. In base 16, the digits 0-9 and the letters A to F are utilized. A symbolizes 10 (base 10), B symbolizes 11 (base 10), and so forth. Digit positions symbolize successive pow

  • 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

  • Q : Explain Branch instruction Branch

    Branch instruction: It stores a new instruction address into the program counter. The consequence of this is the next instruction to be fetched will not generally be the one instantly following the branch instruction. Therefore the normal chronologica

  • Q : Explain the term an XHTML element

    Explain the term an XHTML element attribute.

  • Q : Kernel Mode Illustrate what are the

    Illustrate what are the different functions of Kernel Mode, interrupts and system calls?

  • Q : Main function of context switching What

    What is the main function of context switching?

  • Q : Component which are used in 2nd layer

    What are the different types of component parts which are used in 2nd layer?

  • Q : Ffunction of DynamicPopulateExtender

    What is the function of DynamicPopulateExtender control?

©TutorsGlobe All rights reserved 2022-2023.