Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

COBOL Question: The following is what I currently have: IDENTIFICATION DIVISION. PROGRAM-ID. HW. DATA DIVISION. WORKING-STORAGE SECTION. 01 COUNTER PIC S99. 01 BOTTLES PIC Z9.

COBOL Question:

The following is what I currently have:

IDENTIFICATION DIVISION. PROGRAM-ID. HW.

DATA DIVISION. WORKING-STORAGE SECTION. 01 COUNTER PIC S99. 01 BOTTLES PIC Z9. 01 BOTTLES-REMAINING PIC Z9. 01 NUM PIC s9(02) VALUE 0. PROCEDURE DIVISION. PERFORM VARYING COUNTER FROM 99 BY NUM UNTIL COUNTER = 0 DISPLAY "How many bottles would you like to take down?" ACCEPT NUM MOVE COUNTER to Bottles subtract NUM FROM COUNTER GIVING BOTTLES-REMAINING DISPLAY SPACES EVALUATE COUNTER WHEN 1 DISPLAY " 1 bottle of beer on the wall, " " 1 bottle of beer." DISPLAY "Take one down and pass it around, " "no more bottles of beer on the wall." WHEN 2 Thru 99 DISPLAY BOTTLES " bottles of beer on the wall, " BOTTLES " bottles of beer." DISPLAY "Take one down and pass it around, " BOTTLES-REMAINING " bottles of beer on the wall." END-EVALUATE END-PERFORM GOBACK.

I need to make the NUM clause negative in the following statement (or the data division) so it will subtract from the counter:

PERFORM VARYING COUNTER FROM 99 BY NUM UNTIL COUNTER = 0

I may be overlooking something simple or just completely thinking about this the wrong way.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

3. Is it a topic that your audience will find worthwhile?

Answered: 1 week ago

Question

2. Does the topic meet the criteria specified in the assignment?

Answered: 1 week ago