COBOL programming assignment - Write an interactive COBOL program that will chec
ID: 3859480 • Letter: C
Question
COBOL programming assignment
- Write an interactive COBOL program that will check a VIN entered from the keyboard and display whether it is valid.
- The program must indicate why the VIN is invalid and must continue to validate VINs until the user indicates that there are no more VINs to validate.
- Once the user indicates that there are no more VINs to validate, the program displays a message indicating the total number of valid and invalid VINs that were processed.
* Use SCREEN SECTION to capture the VIN from the user, indicate each VIN validity, and display the validation results. For this assignment extended ACCEPT and DISPLAY statements ARE NOT ALLOWED.
Explanation / Answer
Answer:
IDENTIFICATION DIVISION.
PROGRAM-ID. CHECKNUMB.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INPUT-ID PIC 9(12).
PROCEDURE DIVISION.
MOVE 'abc' TO INPUT-ID
PERFORM CHECK-CORRECT-12-NUMB
MOVE 001234567890 TO INPUT-ID
PERFORM CHECK-CORRECT-12-NUMB
MOVE 1234567890 TO INPUT-ID
PERFORM CHECK-CORRECT-12-NUMB
MOVE 12345678901 TO INPUT-ID
PERFORM CHECK-CORRECT-12-NUMB
MOVE 123456789012 TO INPUT-ID
PERFORM CHECK-CORRECT-12-NUMB
GOBACK.
CHECK-CORRECT-12-NUMB SECTION.
DISPLAY 'checking input: ' INPUT-ID
IF INPUT-ID IS NUMERIC
DISPLAY 'is numeric'
IF INPUT-ID > 99999999999
DISPLAY 'correct! 12 digits entered!'
ELSE
DISPLAY 'expected 12 digits!'
END-IF
ELSE
DISPLAY 'non numeric entered'
END-IF
DISPLAY '-------'
CONTINUE
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.