Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a COBOL program that will convert a literal date, for example Jan 31,2011,

ID: 3693288 • Letter: W

Question

Write a COBOL program that will convert a literal date, for example Jan 31,2011, to a Julian date, for example 0312011 (the 1st three digits are the day of the year and the 2nd four digits are the year). Your program will use a table defined in the program that contains the three characters for the month and the days in the month, for example:

Month       Days in Month

JAN

031

FEB

028

MAR

031

etc.

For this project there will be no leap year. The input records will contain a literal date, for example, MAR 25, 2012. Your program will use the inputed month to search the table for an equal comparison. The program must also total the days in the table to determine the correct day of the year. The printed output will be the literal date and the equivalent Julian date, for example, MAR 25, 2012  CONVERTS TO: 0842012.

Example DATA DIVISION definition of Input record:

01     RECORD-IN.

         02       MONTH-IN     PIC   XXX.

         02       FILLER           PIC   X.

         02       DAY-IN          PIC   99.

         02       FILLER           PIC XX.

         02       YEAR-IN        PIC 9999.

         02       FILLER          PIC X(68).

JAN

031

FEB

028

MAR

031

etc.

Explanation / Answer

A function-identifier is a syntactically correct sequence of character
    strings and separators that uniquely references the data item resulting
    from the evaluation of a function.

    |--- Format -------------------------------------------------------------|
    |                                                                        |
    | >>--FUNCTION--function-name-1--|----------------------|--------------> |
    |                                |    <------------|    |                |
    |                                |-(----argument-1-|--)-|                |
    |                                                                        |
    | >--|--------------------|------------------------------------------->< |
    |    |-reference-modifier-|                                              |
    |                                                                        |
    |------------------------------------------------------------------------|
    argument-1
        Must be an identifier, literal (other than a figurative constant), or
        arithmetic expression.

        For more information, see "Intrinsic Functions" in topic 7.1.

    function-name-1
        Function-name-1 must be one of the Intrinsic Function names.

    reference-modifier
        May be specified only for functions of the category alphanumeric


    A function-identifier that makes reference to an alphanumeric function may
    be specified anywhere that an identifier is permitted and where references
    to functions are not specifically prohibited, except as follows:

    *   As a receiving operand of any statement

    *   Where a data item is required to have particular characteristics (such
        as class and category, size, sign, and permissible values) and the
        evaluation of the function according to its definition and the
        particular arguments specified would not have these characteristics.


    A function-identifier that makes reference to an integer or numeric
    function may be used wherever an arithmetic expression is allowed.


7.1.15 DATE-OF-INTEGER
Ü Copyright IBM Corp. 1991, 1995

    The DATE-OF-INTEGER function converts a date in the Gregorian calendar
    from integer date form to standard date form (YYYYMMDD).

    The function type is integer.

    The function result is an eight-digit integer.

    |--- Format -------------------------------------------------------------|
    |                                                                        |
    | >>--FUNCTION DATE-OF-INTEGER--(argument-1)-------------------------->< |
    |                                                                        |
    |------------------------------------------------------------------------|
    argument-1
        A positive integer that represents a number of days succeeding
        December 31, 1600, in the Gregorian calendar.  The valid range is 1 to
        3,067,671, which corresponds to dates ranging from January 1, 1601
        thru December 31, 9999.

  |      PICTURE 331 Under MVS and VM, the INTDATE installation option affects
  |     the starting date for the integer date functions.  For details, see
  |     the IBM COBOL for MVS & VM Programming Guide. PICTURE 332



7.1.19 INTEGER-OF-DATE
Ü Copyright IBM Corp. 1991, 1995

    The INTEGER-OF-DATE function converts a date in the Gregorian calendar
    from standard date form (YYYYMMDD) to integer date form.

    The function type is integer.

    The function result is a seven-digit integer with a range from 1 to
    3,067,671.

    |--- Format -------------------------------------------------------------|
    |                                                                        |
    | >>--FUNCTION INTEGER-OF-DATE--(argument-1)-------------------------->< |
    |                                                                        |
    |------------------------------------------------------------------------|
    argument-1
        Must be an integer of the form YYYYMMDD, whose value is obtained from
        the calculation (YYYY * 10,000) + (MM * 100) + DD.

        *   YYYY represents the year in the Gregorian calendar.  It must be an
            integer greater than 1600, but not greater than 9999.

        *   MM represents a month and must be a positive integer less than 13.

        *   DD represents a day and must be a positive integer less than 32,
            provided that it is valid for the specified month and year
            combination.



    The returned value is an integer that is the number of days the date
    represented by argument-1, succeeds December 31, 1600 in the Gregorian
    calendar.

  |  PICTURE 335 Under MVS and VM, the INTDATE installation option affects the
  | starting date for the integer date functions.  For details, see the IBM
  | COBOL for MVS & VM Programming Guide. PICTURE 336


7.1.20 INTEGER-OF-DAY
Ü Copyright IBM Corp. 1991, 1995

    The INTEGER-OF-DAY function converts a date in the Gregorian calendar from
    Julian date form (YYYYDDD) to integer date form.

    The function type is integer.

    The function result is a seven-digit integer.

    |--- Format -------------------------------------------------------------|
    |                                                                        |
    | >>--FUNCTION INTEGER-OF-DAY--(argument-1)--------------------------->< |
    |                                                                        |
    |------------------------------------------------------------------------|
    argument-1
        Must be an integer of the form YYYYDDD whose value is obtained from
        the calculation (YYYY * 1000) + DDD.

        *   YYYY represents the year in the Gregorian calendar.  It must be an
            integer greater than 1600, but not greater than 9999.

        *   DDD represents the day of the year.  It must be a positive integer
            less than 367, provided that it is valid for the year specified.


  |      PICTURE 337 Under MVS and VM, the INTDATE installation option affects
  |     the starting date for the integer date functions.  For details, see
  |     the IBM COBOL for MVS & VM Programming Guide. PICTURE 338


    The returned value is an integer that is the number of days the date
    represented by argument-1, succeeds December 31, 1600 in the Gregorian
    calendar.

    The returned value represents the International Standards Organization
    (ISO) standard date equivalent to the integer specified as argument-1.

    The returned value is an integer of the form YYYYMMDD where YYYY
    represents a year in the Gregorian calendar; MM represents the month of
    that year; and DD represents the day of that month.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote