{ Ben Weir - CIS 31
Program 5 - Horoscopes
Last modified: 10-28-96
Name: a5p1
This program accepts as input a month and day and then
displays the proper horoscope. If the day is within 2
days from another sign, it also shows that horoscope.
}
uses crt;
var
monthnum: integer; {month they were born in }
day: integer; {day of year they were born}
key: char; {either 'y' or 'n' to repeat program}
type
monthname = array[1..12] of string[9]; {to hold monthnames}
monthdays = array[1..12] of byte; {to hold days in each month}
horo = array[1..12] of string[80]; {to hold horoscope text}
signname = array[1..12] of string[11]; {to hold the name of the sign}
const
month:monthname = ('January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November',
'December'); {list of all the months}
sign:signname = ('Capricorn', 'Aquarius', 'Pisces', 'Aries', 'Taurus',
'Gemini', 'Cancer', 'Leo', 'Virgo', 'Libra', 'Scorpio',
'Sagittarius'); {list of all the signs}
numdays:monthdays = (31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
{list of the days in each month}
horoscope:horo = ( {data for horoscopes}
{jan} 'You will be prosperous',
{feb} 'You will die soon',
{mar} 'You will buy something big soon',
{apr} 'The winning lottery numbers are 05 32 88 92 95 98',
{may} 'You have just won a new car',
{jun} 'You will take up bungee jumping in the near future',
{jul} 'Giving Ben Weir an A is the key to a long and happy life',
{aug} 'Your house is on fire',
{sept}'Be kind to your spouse or you will no longer have one.',
{oct} 'Preparing hard disk for low level format, all data will be lost...',
{nov} 'How much wood could a wood chuck chuck if a wood chuck could chuck wood?',
{dec} 'Ah, lovely isn''t it?');
Procedure GetData(var monthnum, day: integer);
begin
ClrScr;
repeat
GotoXY(1,1);
write('What month were you born in (1-12)? '); {get month, make sure}
readln(monthnum); {it's valid}
until (monthnum > 0) and (monthnum < 13);
repeat
GotoXY(1,2);
write('What day of ', month[monthnum], ' were you born in (1-', numdays[monthnum], ')? ');
readln(day); {get day, make sure}
until (day > 0) and (day < numdays[monthnum] + 1); {it's valid}
end; {getData}
Procedure ShowHoro(monthnum: integer);
begin
writeln('---------------------');
writeln('Horoscope for ', sign[monthnum], ':');
writeln('** ', horoscope[monthnum], ' **');
writeln('---------------------');
end; {ShowHoro}
Procedure Cusp(monthnum: integer);
begin
writeln('You are on a cusp!');
ShowHoro(monthnum);
end; {Cusp}
Procedure WhichToShow(monthnum, day: integer);
var
nextmonth: integer;
begin
nextmonth := (monthnum) mod 12 + 1;
if (day >= 1) and (day <= 23) then ShowHoro(monthnum);{if they're between}
if (day >= 19) and (day <= 31) then Cusp(nextmonth); {19 and 23 show both}
end; {whichtoshow}
begin
repeat
GetData(monthnum, day); {get birthday info}
WhichToShow(monthnum, day); {process/display it}
write('Do it again (Y/N)? '); {prompt user to repeat program}
repeat {loop until they answer y or n}
key := readkey;
until (key = 'y') or (key = 'n');
until key = 'n';
end. {program a5p1}
               (
geocities.com/siliconvalley/park)                   (
geocities.com/siliconvalley)