Вы находитесь на странице: 1из 4

CISB323 BUSINESS PROGRAMMING

LAB 1
After completing this lab, you should be able to:
Identify four divisions of a COBOL program
Explain the purpose of each divisions in a COBOL program
Distinguish between constants and variables
Declare variable using an appropriate level, data-name and PICTURE clause
Use MOVE verb to assign data to a variable
Use ACCEPT verb to read user input
Use DISPLAY verb to display program output
Use COMPUTE verb for arithmetic operations
Use PERFORM verb where necessary

A. PRE-LAB ACTIVITIES
Answer following questions:
1. COBOL is a machine language. True or False?
2. PROGRAM-ID is a required entry in what division?
3. The first division in a COBOL program is _________________.
4. What division defines the filenames and describes the specific computer equipment that
will be used by the program?
5. What division of a COBOL program defines the input and output formats?
6. What division contains the instructions for reading input, processing it, and creating
output?
7. State the difference between constant and variable?
8. Create a variable called TaxAmount to hold a value between 0 and 99,999.99.
9. Create an alphanumeric variable called VideoName large enough to hold 35 characters.
10. A variable called MinimumWage is defined as PIC 9V99. Show what happens to the
data after execution of the statement
MOVE 123.5 TO MinimumWage
MinimumWage

B. LAB ACTIVITIES
1

CISB323 BUSINESS PROGRAMMING

Question 1
Identify the divisions, sections, paragraph, sentences and statements from following program
code in Listing 1.1:

IDENTIFICATION DIVISION.
PROGRAM-ID. Add.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 FirstNumber
PIC 99.
01 SecondNUmber
PIC 99.
01 TheResult
PIC 999.
PROCEDURE DIVISION.
PROGRAM-BEGIN.
DISPLAY Enter the first number..
ACCEPT FirstNumber.
DISPLAY Enter the second number..
ACCEPT SecondNumber.
COMPUTE TheResult = FirstNumber + SecondNumber.
DISPLAY The result is: .
DISPLAY TheResult.
PROGRAM-DONE.
STOP RUN.
Listing 1.1

Question 2
Given the description of BirthDate in Listing 1.2, what do you think would be displayed
by the COBOL code in Listing 1.3?
01 BirthDate.
02 YearOfBirth.
03 CenturyOB
03 YearOB
02 MonthOfBirth
02 DayOfBirth

PIC
PIC
PIC
PIC

99.
99.
99.
99.

Listing 1.2
MOVE 19750215 TO BirthDate.
DISPLAY Month is = MonthOfBirth
DISPLAY Century of birth is = CenturyOB
DISPLAY Year of birth is = YearOfBirth
DISPLAY DayOfBirth / MonthOfBirth / YearOfBirth

Listing 1.3

Question 3
A variable CustomerRec is defined in Listing 1.4:
01 CustomerRec.
02 CustId
02 CustName.
03 Initials
03 Surname
02 Gender
02 Payment

PIC 9(5).
PIC
PIC
PIC
PIC

XX.
X(4).
X.
9(5)V99.

CISB323 BUSINESS PROGRAMMING

Listing 1.4
1. A partial diagram representing CustomerRec is provided. Complete the diagram by
showing how the subdivision variables map to the 19 characters of storage reserved
for CustomerRec.
2. For each statement in the following program, show what happens to the data in
CustomerRec. Use a row for each statement.
PROCEDURE DIVISION.
PROGRAM-BEGIN.
MOVE 45145MCRyanF23445.67 TO CustomerRec
MOVE Male TO Gender
MOVE GSPower TO CustName
MOVE Fitzroy TO Surname
MOVE 34 TO Payment
STOP RUN.

Question 4
Write a program to calculate the perimeter and area of a rectangle. The length and width is
entered by the user.
Question 5
Write a program to convert your weight to pound and display it. Assume your weight is 56
kilograms.
Hint: 1 kg = 2.2 pounds
Question 6
Write a program to calculate and display average sales of three employees.
Questions 7
Your friend asked you to write a program that calculates the area of rectangle and total price
of a tile. The program will receive a length and width, in feet, of a rectangle, and the price of
a square foot of a tile.
Question 8
3

CISB323 BUSINESS PROGRAMMING

Modify the program in Question 4-7 to utilize PERFORM verb.

Вам также может понравиться