01 · Structure and Divisions
- IDENTIFICATION
- ENVIRONMENT
- DATA
- PROCEDURE
- WORKING-STORAGE
- PICTURE
- VALUE
End of the COBOL Course
Congratulations: you have made it through the 4 modules of the COBOL Course — from the fixed layout structure and mandatory divisions, to declaring variables with PICTURE and VALUE, up to formal arithmetic, conditional blocks, modular paragraphs with PERFORM, and finally managing complex data structures such as records and tables with the OCCURS clause. Put your skills to the test with the final challenge.
Reminder: COBOL exercises are verified statically (keywords). To actually run the code, each exercise provides a OneCompiler button that copies the code and opens the sandbox.
Complete the COBOL code snippets to declare a numeric variable, perform an arithmetic calculation, and make a repeated paragraph call.
Declare a numeric variable suitable for a percentage with one integer digit and two decimal places, initialized to 0.05. Module 1 (structure and variables).
Inside the WORKING-STORAGE SECTION, declare a level-01 variable named WS-INTEREST-RATE, with PICTURE "9V99" and initial value "0.05".
Use the correct format: "01 WS-INTEREST-RATE PIC 9V99 VALUE 0.05." (always terminate COBOL statements with a period).
Solution available after 3 attempts
Calculate the interest amount by multiplying the balance by the interest rate. Module 2 (arithmetic and computation).
Write the COMPUTE statement to calculate the value of WS-INTEREST-AMOUNT by multiplying WS-BALANCE by WS-INTEREST-RATE.
Use the syntax: "COMPUTE WS-INTEREST-AMOUNT = WS-BALANCE * WS-INTEREST-RATE."
Solution available after 3 attempts
Repeatedly invoke the paragraph that applies interests to simulate interest accumulation over 5 years. Module 3 (paragraphs and loops).
Inside the PROCEDURE DIVISION, invoke the CALCULATE-INTEREST paragraph exactly 5 times using the PERFORM statement.
Use: "PERFORM CALCULATE-INTEREST 5 TIMES." or the TIMES clause.
Solution available after 3 attempts
A single page with all the essential syntax of COBOL, ready to keep handy while you code.
Consistent practice is the best way to strengthen your skills. Open the COBOL Playground to experiment freely with complex scenarios or to prepare your code snippets before testing them on OneCompiler.