Logo 
Search:

Cobol Articles

Submit Article
Home » Articles » Cobol » Homework HelpRSS Feeds

Program to check entered date is valid birth date or not

Posted By: Ethan Evans     Category: Cobol     Views: 6204

Write a Program to check entered date is valid birth date or not.

Code for Program to check entered date is valid birth date or not in Cobol

       IDENTIFICATION DIVISION.
       PROGRAM-ID. 
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 DATE1.
           02 YY    PIC 99.
           02 MM    PIC 99.
           02 DD    PIC 99.
       01 BIRDATE.
           02 BYY  PIC 9999.
           02 BMM  PIC 99.
           02 BDD  PIC 99.
       PROCEDURE DIVISION.
       MAIN-PARA.
           DISPLAY "-----------------------------------------------".
           ACCEPT DATE1 FROM DATE.
           DISPLAY " CURRENT DATE:- " DD "/" MM "/" YY.
           DISPLAY "-----------------------------------------------".
           DISPLAY " ENTER THE BIRTH-DATE(YYYYMMDD):- ".
           ACCEPT BIRDATE.
           COMPUTE YY = YY + 1906.
           IF  YY < BYY
                DISPLAY " DATE IS INVALID "
                EXIT
           ELSE
                IF MM < BMM
                        COMPUTE BMM = 12 - BMM
                        COMPUTE BMM = MM + BMM
                        COMPUTE BYY = BYY - 1
                ELSE IF MM = BMM AND DD < BDD
                        COMPUTE BYY = BYY - 1
                        COMPUTE BMM = MM - BMM

                ELSE
                        COMPUTE BMM = MM - BMM.


                IF DD < BDD
                        COMPUTE BDD = 30 - BDD
                        COMPUTE BDD = DD + BDD 
                        COMPUTE BMM = MM - 1
                ELSE
                        COMPUTE BDD = DD - BDD.

                DISPLAY ( 15 , 30 )  " AGE IS ".
                DISPLAY ( 17 , 30 )BYY " YEARS " BMM " MONTHS " BDD " DAYS ".
                STOP RUN.
  
Share: 


Didn't find what you were looking for? Find more on Program to check entered date is valid birth date or not Or get search suggestion and latest updates.

Ethan Evans
Ethan Evans author of Program to check entered date is valid birth date or not is from London, United Kingdom.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!