Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help On a Little Cobol Program

Status
Not open for further replies.

Myles882

Programmer
Sep 6, 2001
1
US
Yes i have to make a Cobol Program about the signs of the months, like Leo for august and so on..but i'm not sure where to start at all..My project says to make a program that shows a option "Enter a month and day" and then the sign will come up and then a question " Continue YEs or No" PLease Help I DONT WANT TO fail out of schooL :( Thanks Myles
 
Myles,

What they're looking for is a pgm that will return an astrological sign when given the month and day that the term user was born. What do you know about astrology? I don't know much, but I do know that each sign has a date range associated w/it. All you have to know to solve the problem is the ranges of each sign.

Enough to get you started?

Jack
 
hello Myles882,
Take one of the first programs in "Teach yourself cobol in 21 days" and try to adapt it. You will learn a lot and do what you have to do.This book is also on the internet.
good luck
 
Look at an astrological chart then count how many days is is to the end of the "sign" from the beginning of the year.

Then when someone enters a date, convert that to a number from Jan 1 (ie June 30 becomes 180 or whatever). You should be able to find a COBOL library routine that will figure this out for you. If you can't you'll have to develop some more coding to generate the date (remember leap year!).

From then on it's just a set of if statements or case statement to find the sign -

01 ASTRO_BREAK_DATES
03 GOPHER_DATE pic 999 value 10.
03 AARDVAARK_DATE pic 999 value 27.
etc...
ie
IF DATE_ENTERED < GOPHER_DATE
ASTRO_SIGN = GOPHER
ELSE IF DATE_ENTERED < AARDVAARK_DATE
ASTRO_SIGN = AARDVAARK
....
ELSE
ASTRO_SIGN = SIGN_AT_END_OF_YEAR
END IF.

Another way would be:

IF MONTH_ENTERED = JANUARY
IF DATE_ENTERED < 10
ASTRO_SIGN = GOPHER
ELSE IF DATE_ENTERED < 27
ASTRO_SIGN = AARDVAARK
ELSE
ASTRO_SIGN = HORSE
END IF
ELSE IF MONTH_ENTERED = FEBRUARY
IF DATE_ENTERED <
etc...

There is more than one way to code it but until you understand what you're doing, the simpler, the better even if it's more wordy. If you do use <, make sure you do your if staements in ascending numerical order
(Ie if PUPPY_DATE is 137 and you put it as the first &quot;if&quot;, it would be true for ALL dates less than 137 even if the date entered = 12 and should have been AARDVAARK).

Good luck. What you are worried about is not COBOL coding but a thought process on how to solve a problem. Once you get that skill down, you can program in almost any language.

One good habit to get into is to make it object oriented - use OBJECTS instead of numbers in the program - ie AARDVAARK_DATE instead of 10, etc. It won't make a big difference here but may save you a LOT of time later on - plus create a more professional program.


 
Tell your instructor that your religion considers astrology to be &quot;devil magic&quot;, and you need a different assignment.

Stephen :)
 
Hi,

For the sign problem, look at this example:

Code:
000100*$CALL
000200 IDENTIFICATION DIVISION.
000300 PROGRAM-ID. THESIGNS.
000400 ENVIRONMENT DIVISION.
000500 CONFIGURATION SECTION.
000600 SOURCE-COMPUTER. IBM-PC.
000700 OBJECT-COMPUTER. IBM-PC.
000800 SPECIAL-NAMES.
000900     CONSOLE IS CONSOLE
001000     DECIMAL-POINT IS COMMA.
001100 INPUT-OUTPUT SECTION.
001200 FILE-CONTROL.
001300 DATA DIVISION.
001400 WORKING-STORAGE SECTION.
001410 01  MONTH-SIGN-TABLE.
001420     03  VALUE &quot;SIGN OF JANUARI    &quot; PIC X(20).
001430     03  VALUE &quot;SIGN OF FEBRUARI   &quot; PIC X(20).
001440     03  VALUE &quot;SIGN OF MARCH      &quot; PIC X(20).
001450     03  VALUE &quot;ETC.               &quot; PIC X(20).
001451     03  VALUE &quot;ETC.               &quot; PIC X(20).
001452     03  VALUE &quot;ETC.               &quot; PIC X(20).
001453     03  VALUE &quot;ETC.               &quot; PIC X(20).
001454     03  VALUE &quot;LEO FOR AUGUST     &quot; PIC X(20).
001455     03  VALUE &quot;ETC.               &quot; PIC X(20).
001456     03  VALUE &quot;ETC.               &quot; PIC X(20).
001457     03  VALUE &quot;ETC.               &quot; PIC X(20).
001458     03  VALUE &quot;SIGN OF DECEMBER   &quot; PIC X(20).
001468 01  MONTH-SIGN-TABLE-RED REDEFINES MONTH-SIGN-TABLE.
001478     03  MONTH-SIGN       OCCURS 12  PIC X(20).
001488
001498 01  MONTH-INPUT                     PIC 99.
002400 PROCEDURE DIVISION.
002500 0001.
002600     DISPLAY
002601     &quot;For what month (in numbers) you want to know the sign?&quot;.
002610     ACCEPT MONTH-INPUT.
002611     IF MONTH-INPUT > 0 AND < 13
002620         DISPLAY &quot;The sign is: &quot; MONTH-SIGN(MONTH-INPUT)
002630     ELSE
002640         DISPLAY &quot;Sorry, but this month does not exists here..&quot;
002650     END-IF
002660     .
002700 0003.
002710     STOP RUN.

[\code]

I hope this is helpful

Regards,

   Crox
 
Let me do a take on this. Though the other suggestions have been excellent.

You want to write a program where, if the user inputs a month, what will be returned will be what is considered the Astrological sign for that month.

This is a bit illogical, as the astrological signs mostly spread out between various months. But I am assuming that your assignment arbitrarily assigns &quot;Aquarius&quot; to January, &quot;Pisces&quot; to February, etc. So if a user were to enter &quot;January,&quot; the program would return &quot;Aquarius.&quot;

The way I would do it is to simply make a field which will accomdate the user-entry of the month.

01 MONTH-INPUT PIC X(3) VALUE SPACES.


Then code a series of 88 values such as:

01 SIGN-OUTPUT PIC X(15).
88 AQUARIUS-OUTPUT VALUE 'AQUARIUS'.
88 PISCES-OUTPUT VALUE 'PISCES'.
88 ARIES-OUTPUT VALUE 'ARIES'


And etc. for all the other signs.

Then, in the procedure division, code something like the following:

EVALUATE MONTH-INPUT
WHEN 'JAN'
SET AQUARIUS-OUTPUT TO TRUE
WHEN 'FEB'
SET PISCES-OUTPUT TO TRUE


And so forth, for each of the months and outputs. At the end, in case the user mistakenly enters something other than a month, make sure to code
WHEN OTHER
DISPLAY ERROR-MESSAGE [whatever your error message is]
END-EVALUATE.


Then have whatever value has been set to TRUE be displayed on the user's screen.

Hope this helps, Nina Too
 
And what if his teacher asks about a guy named Jackson? BigMag, The Netherlands.
someone@euronet.nl (no kidding!)
 
Stephen,

utterly useless suggestion, but very funny! Might even work...

Regards,
Ronald.
 
Hi BigMag,

Tell us more about Jackson in this case...

Regards,

Crox
 
Crox,

Felt it comming...

It's just what &quot;nontrad&quot; said: &quot;What you are worried about is not COBOL coding but a thought process on how to solve a problem. Once you get that skill down, you can program in almost any language.&quot;

Therefore you must acquire a stuctured way of thinking which is more important than the coding itself.

Jackson wrote al lot about this. &quot;Jackson Stuctured Programming&quot;
Another method is &quot;Volmac Structured Programming&quot; developed by Cap.


But..., I'm lucky, there's a nice fellow, named Crox, who can tell everything about Jackson and who might copy and paste something about Jackson (provided that someone kindly asks).

Greetings,

M.

nog 9 dagen...
BigMag, The Netherlands.
someone@euronet.nl (no kidding!)
 
Thanks for the requote complement. I had never heard of Jackson before.

My knowledge is from the 16-week course at Keesler AFB called &quot;Computer Systems Development Officer&quot;. I called it the &quot;Grace Hopper School of Programming&quot;. Even in 1982, the first things that were taught were program design, structure and object-oriented programming methodology. COBOL was my first language but my ability to program/understand other languages stems from the first few weeks of that course.

(Yep, I had two &quot;nanoseconds&quot; from lectures from &quot;the female Rickover&quot; but they got lost in one of my various moves )
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top