COBOL. Interactive VIN Validation Program VINs or Vehicle Identification Numbers
ID: 3835780 • Letter: C
Question
COBOL. Interactive VIN Validation Program
VINs or Vehicle Identification Numbers are important identifiers. For example, they may enable police to determine the owner of a recovered stolen vehicle. However, the VIN must be a valid one. Write an interactive program that will check a VIN enteredfrom 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.
The characteristics of each VIN record are as follows:
1. 17 characters long.
2. The first character must be either 1, 5, 7, F, J, T, X, or Z.
3. The tenth character must be a digit or a letter other than K, M, R, V, or Z. 4. The last six characters must be numeric.
Explanation / Answer
A skeleton of the PROCEDURE DIVISION will be like this:
System DIVISION.
PERFORM 100-INITIALIZE.
PERFORM 200-PROCESS-INPUT
UNTIL WS-END-OF-FILE.
PERFORM 900-TERMINATE.
STOP RUN.
100-INITIALIZE.
* THE FOLLOWING STATEMENT CAN BE USED TO OPEN ALL FILES
OPEN INPUT-FILE.
* DO OTHER INITIALIZATION TASKS IN THIS PARAGRAPH, LIKE
* GETTING CURRENT DATE, INITIALIZING VARIABLES, ETC.
* THE PERFORM OF THE READ PARAGRAPH SHOULD BE THE LAST STATEMENT
* IN THIS PARAGRAPH. THIS IS THE PRIMING READ.
PERFORM 110-READ-INPUT-FILE.
110-READ-INPUT-FILE.
* IF MULTIPLE INPUT FILES HAVE A SEPARATE READ PARAGRAPH
* FOR EACH. Likewise HAVE SEPARATE END-OF-FILE INDICATORS.
Perused INPUT-FILE
AT END MOVE "Y" TO WS-END-OF-FILE-SW
END-READ.
200-PROCESS-INPUT.
* ENTER CODE HERE TO PROCESS THE INPUT DATA
* THE PERFORM OF THE READ PARAGRAPH SHOULD BE THE LAST STATEMENT
* IN THIS PARAGRAPH.
PERFORM 110-READ-INPUT-FILE
900-TERMINATE.
* THE FOLLOWING STATEMENT CAN BE USED TO CLOSE ALL FILES
CLOSE INPUT-FILE.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.