Question: Question about COBOL. I have the following program: IDENTIFICATION DIVISION. PROGRAM-ID. Multiplier. AUTHOR. James P Lucas DATE-WRITTEN. Jan 31, 2018 * Example program using ACCEPT,

Question about COBOL. I have the following program:

IDENTIFICATION DIVISION. PROGRAM-ID. Multiplier. AUTHOR. James P Lucas DATE-WRITTEN. Jan 31, 2018 * Example program using ACCEPT, DISPLAY and MULTIPLY to * get two single digit numbers from the user and multiply them * together ENVIRONMENT DIVISION.

DATA DIVISION.

WORKING-STORAGE SECTION. 01 Num1 PIC 9 VALUE ZEROS. 01 Num2 PIC 9 VALUE ZEROS. 01 Num3 PIC 99 VALUE ZEROS. 01 Num4 pic 99 value zeros. 01 Num5 pic 99 value zeros. 01 Result PIC 999 VALUE ZEROS.

PROCEDURE DIVISION. DISPLAY "Enter first number (1 digit) : " WITH NO ADVANCING. ACCEPT Num1. DISPLAY "Enter second number (1 digit) : " WITH NO ADVANCING. ACCEPT Num2. DISPLAY "Enter third number (1 digit) : " WITH NO ADVANCING. ACCEPT Num3. DISPLAY "Enter fourth number (1 digit) : " WITH NO ADVANCING. ACCEPT Num4. DISPLAY "Enter fifth number (1 digit) : " WITH NO ADVANCING. ACCEPT Num5. MULTIPLY Num1 by num2 by Num3 by Num4 By Num5 giving Result. DISPLAY "Result is = ", Result. ADD Num1, num2, num3, num4, num5 giving Result. DIVIDE Result by 5 giving Result. DISPLAY "Average is = ", Result. STOP RUN.

I am trying to get it to compile 5 numbers instead of just 2, and the instructions are as follows:

Prompt for 3 more numbers (all integers picture clause of 99)

Calculate the average of all five numbers.

Print your name and date

Print the five numbers and the average

Hints:

You will need to create working storage variables which are integer. The numbers to be read in will have 2 digits (picture clause of 99). The addition of the 5 numbers will need a picture clause of 999. (3 digits)

To add you would use the following syntax:

ADD value1 value2 value3 value4 value5 giving total.

To divide, you would use the following syntax:

DIVIDE total by 5 GIVING average.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!