Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Compile and Execute COBOL Online

IDENTIFICATION DIVISION.
PROGRAM-ID. HW01FL.
AUTHOR.     STUDENT NAME.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-PROFESSOR-NAME       PICTURE X(08) VALUE 'Lovelace'.

01 WS-COURSE-SCORE-IN      PICTURE X(03).
01 WS-COURSE-SCORE REDEFINES
   WS-COURSE-SCORE-IN      PICTURE 9(03).

01 WS-POINTS-POSSIBLE      PICTURE 9(03) VALUE 105.
01 WS-PASSING-GRADE        PICTURE 9(02) VALUE 70.
01 WS-POINTS-ABOVE-PASSING PICTURE 9(02) VALUE 0.

01 WS-POINT-FEE            PIC     9(02)V99 VALUE 3.00.
01 WS-DOLLARS-EARNED       PIC     9(02)v99 VALUE 0.
01 WS-FORMATTED-DOLLARS    PIC     $$9.00.

PROCEDURE DIVISION.
    DISPLAY 'Hello, Professor 'WS-PROFESSOR-NAME' Here'.
    ACCEPT WS-COURSE-SCORE-IN.
    DISPLAY "SCORE ENTERED: " WS-COURSE-SCORE-IN.
    IF WS-COURSE-SCORE-IN IS NUMERIC AND 
       WS-COURSE-SCORE >= 0 AND WS-COURSE-SCORE <= 100
      IF WS-COURSE-SCORE > 69 
        DISPLAY 'You Passed the Course with a score of: '
                 WS-COURSE-SCORE
        COMPUTE WS-POINTS-ABOVE-PASSING =
                WS-COURSE-SCORE - WS-PASSING-GRADE 
        DISPLAY 'You have passed by ' WS-POINTS-ABOVE-PASSING ' points'  
        COMPUTE WS-DOLLARS-EARNED = WS-POINTS-ABOVE-PASSING * WS-POINT-FEE
        MOVE WS-DOLLARS-EARNED TO WS-FORMATTED-DOLLARS
        DISPLAY "You earned a " WS-FORMATTED-DOLLARS " BONUS"
      ELSE 
        DISPLAY 'Oh no...Your score of 'WS-COURSE-SCORE' did not pass'
        DISPLAY 'A score below 'WS-PASSING-GRADE' is a failing grade'
    ELSE
      DISPLAY "The Score of " WS-COURSE-SCORE " entered is not correct"
      DISPLAY "Score entered " WS-COURSE-SCORE-IN " is not correct"
      DISPLAY "Enter a numberic score from 000 to 100, including"
              " leading zeroes".
    
    STOP RUN.

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.