26. How do you create an object of a class, in COBOL? 27. Write the code to test if ITEM contains both letters and numbers. 28. . Given the following code: 05 IMPATIENS-COLOR PIC 9. 88 RED VALUE 1. 88 PINK VALUE 2. 88 ORANGE VALUE 3. Write the EVALUATE statement to validate this input. 29. The weekly payroll program for an Internet start-up company contains an input field, HOURS-IN with PIC 999. Employees routinely work long hours, but no one is permitted to work more than 150 hours in a week. Write the PROCEDURE DIVISION code to validate the data input. Use EVALUATE. 30. Write the code to count the number of occurrences of the digit 6 until the first space is encountered in ITEM. Use A-COUNT as the storage parameter. 31. Write the PROCEDURE DIVISION code segment to sum all the numbers from 1 through 100. Use an in-line PERFORM UNTIL. 32. . Write the PROCEDURE DIVISION code segment to sum all the numbers from 1 through 100. Use a PERFORM paragraph-name ..TIMES. 33. Given the following code: MOVE 10 TO NUM MOVE 1 TO TOTAL a) Recode this using an in-line PERFORM N TIMES. b) What is output?

26. In COBOL, to create an object of a class, you need to declare an instance of that class using the “CREATE” statement. The class itself must be defined using the “CLASS” keyword in the DATA DIVISION section. Once the class is defined, you can use the “CREATE” statement followed by the class name to create an object instance. For example:

DATA DIVISION.
CLASS MyClass.
01 MyClass-Object OBJECT REFERENCE IS HANDLE OF MyClass.
PROCEDURE DIVISION.
CREATE MyClass-Object.

This code declares a class called “MyClass” in the DATA DIVISION section and then uses the “CREATE” statement to create an object instance called “MyClass-Object” in the PROCEDURE DIVISION section.

27. To test if ITEM contains both letters and numbers, you can use the “INSPECT” verb in COBOL. The “INSPECT” verb allows you to perform pattern matching and manipulation on character strings. In this case, you can use the “INSPECT” verb to search for both letters and numbers in the ITEM string. Here’s an example code:

DATA DIVISION.
WORKING-STORAGE SECTION.
01 ITEM PIC X(10) VALUE “AB12CD34”.
PROCEDURE DIVISION.
INSPECT ITEM TALLYING LETTER-COUNT FOR CHARACTERS
BEFORE ALPHA IS NUMERIC
TALLYING NUMBER-COUNT FOR CHARACTERS
BEFORE NUMERIC IS ALPHABETIC.
DISPLAY “Letter count: ” LETTER-COUNT.
DISPLAY “Number count: ” NUMBER-COUNT.

This code uses the “INSPECT” verb to search for letters and numbers in the ITEM string. The “TALLYING” clause is used to count the number of letters and numbers found. The “FOR CHARACTERS” clause specifies the search pattern, and the “IS NUMERIC” and “IS ALPHABETIC” conditions determine if a character is a number or a letter. The “DISPLAY” statements will show the letter count and number count.

28. The given code defines a named condition for different values of the IMPATIENS-COLOR field. To validate the input, you can use the EVALUATE statement in COBOL. Here’s the code:

DATA DIVISION.
WORKING-STORAGE SECTION.
01 IMPATIENS-COLOR PIC 9.
88 RED VALUE 1.
88 PINK VALUE 2.
88 ORANGE VALUE 3.
PROCEDURE DIVISION.
EVALUATE IMPATIENS-COLOR
WHEN RED
DISPLAY “Color is red”
WHEN PINK
DISPLAY “Color is pink”
WHEN ORANGE
DISPLAY “Color is orange”
WHEN OTHER
DISPLAY “Invalid color”
END-EVALUATE.

This code uses the EVALUATE statement to evaluate the value of the IMPATIENS-COLOR field. Each “WHEN” clause checks for a specific value (in this case, the named conditions RED, PINK, and ORANGE). If the value matches any of the named conditions, the corresponding DISPLAY statement is executed. If the value doesn’t match any of the named conditions, the general “OTHER” clause is executed, indicating an invalid color.

Need your ASSIGNMENT done? Use our paper writing service to score better and meet your deadline.


Click Here to Make an Order Click Here to Hire a Writer