1. Program: Make My Day
- Posted by Alan Tu <ATU5713 at COMPUSERVE.COM>
Sep 05, 1998
-
Last edited Sep 06, 1998
-- Below please find a biorythm calculator. It is yours to do whatever. =
-- Many thanks to Robert B Pilkington for providing inspiration for a day=
s
-- left in year algorithm.
-- bug reports? let me know.
-- This is a milestone for me. From idea creation to this release
-- less than 12 hours
include get.e
include round.e -- Lucius L. Hilley's round.e
constant PI =3D 3.141592653589793
global integer pr, er, ir
function daysoflife()
sequence input, month, day, year, d, days_month
integer bmonth, bday, byear, cyear,
fullyears, counter, daysonearth, daysleft
counter =3D 0
puts(1,"Enter birthdate (mm/dd/yyyy): ")
input =3D gets(0)
input =3D input[1..length(input)-1] -- strip off the line feed
month =3D input[1..2]
day =3D input[4..5]
year =3D input[7..10]
month =3D value(month)
day =3D value(day)
year =3D value(year)
bmonth =3D month[2]
bday =3D day[2]
byear =3D year[2]
d =3D date()
cyear =3D d[1]
cyear =3D cyear+1900
fullyears =3D cyear-byear-1
for i =3D byear+1 to byear+fullyears do
-- calculate number of Feb. 29's
if remainder(i, 400) =3D 0 then counter =3D counter+1
elsif remainder(i, 100) =3D 0 then counter =3D counter+0
elsif remainder(i, 4) =3D 0 then counter =3D counter+1
end if
end for
days_month =3D {31,28,31,30,31,30,31,31,30,31,30,31}
daysleft =3D 0
if bmonth !=3D 12 then -- this routine isn't necessary for December
for i =3D bmonth+1 to 12 do
daysleft =3D daysleft+days_month[i]
end for
end if
daysleft =3D daysleft + (days_month[bmonth]-bday)
-- calculate days left for birth month
daysonearth =3D fullyears*365+counter+daysleft+d[8]
return daysonearth
end function
procedure calc()
integer days
days =3D daysoflife()
pr =3D roundoff(100*sin(2*days*PI/23))
er =3D roundoff(100*sin(2*days*PI/28))
ir =3D roundoff(100*sin(2*days*PI/33))
end procedure
procedure display()
puts(1,"\n\nToday, your physical biorhythm score is: ")
printf(1, "%d", pr)
puts(1,"\n")
puts(1,"Today, your emotional biorhythm score is: ")
printf(1, "%d", er)
puts(1,"\n")
puts(1,"Today, your intellectual biorhythm score is: ")
printf(1, "%d", ir)
puts(1,"\n\n")
puts(1,"Thank you for letting me make you day.")
abort(0)
end procedure
procedure main()
clear_screen()
puts(1,"Make My Day\n")
puts(1,"Biorythm Calculator v1.0\n")
puts(1,"by Alan Tu <atu5713 at compuserve.com>\n\n")
puts(1,"Score is between -100 and 100.\n")
puts(1,"-100 is worst, 0 is median, and 100 is excellent.\n\n")
calc()
display()
end procedure
main()
=