Create Calander with PASCAL - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Create Calander with PASCAL

svr2009wwesvr2009wwe Posts: 1Member
Here's a simple code which will create a monthly calendar for u.

[code]
program CALANDER(input,output);

uses crt;

var
space: integer;
i : integer;
month : integer;
fmonth: string;
MonthA : Array[0..11] of string;
DayA : Array[0..6] of string;
MonthC : Array[0..11] of integer;
day : integer;
fday : string;
DayF : Array[0..6] of integer;
firstday : string;
firstdate : integer;
daymod : integer;
date : integer;
a : integer;
monthtotal: integer;

begin

{ARRAY list that used in program}
{START}
MonthA[0] := 'January';
MonthA[1] := 'February';
MonthA[2] := 'March';
MonthA[3] := 'April';
MonthA[4] := 'May';
MonthA[5] := 'June';
MonthA[6] := 'July';
MonthA[7] := 'Auguest';
MonthA[8] := 'September';
MonthA[9] := 'October';
MonthA[10] := 'November';
MonthA[11] := 'December';

DayA[0] := 'Sunday';
DayA[1] := 'Monday';
DayA[2] := 'Tuesday';
DayA[3] := 'Wednesday';
DayA[4] := 'Thursday';
DayA[5] := 'Friday';
DayA[6] := 'Saturday';

DayF[0] := 0;
DayF[1] := 5;
DayF[2] := 5;
DayF[3] := 5;
DayF[4] := 5;
DayF[5] := 5;
DayF[6] := 5;

MonthC[0] := 31;
MonthC[1] := 28;
MonthC[2] := 31;
MonthC[3] := 30;
MonthC[4] := 31;
MonthC[5] := 30;
MonthC[6] := 31;
MonthC[7] := 31;
MonthC[8] := 30;
MonthC[9] := 31;
MonthC[10] := 30;
MonthC[11] := 31;
{END}

clrscr;
writeln('Enter the current MONTH code from the following list');

{Loop for the Month codes display}
{START}
for i := 0 to 11 do
begin
writeln(i,' => ',MonthA[i]);
end;
{END}

writeln('');
writeln('Please enter the MONTH code between 0 to 11');
readln(month); {Get current month from user}
writeln('');


{Error handeling for getting current month rom user}
{START}
if (month < 0) OR (month >= 12)
then
begin
repeat
writeln('Please enter the MONTH code between 0 to 11');
readln(month);
until ((month >= 0) AND (month <= 11));
fmonth := MonthA[month];
writeln(fmonth);
end
else
begin
if ((month >= 0) AND (month <= 11))
then
begin
fmonth := MonthA[month];
writeln(fmonth);
end
else
writeln('Please Enter Valid Charactor');
end;
{END}


monthtotal:=MonthC[month];



clrscr;
writeln('Please enter month''s First Day from codelist');


{Loop for the Day codes display}
{START}
for i := 0 to 6 do
begin
writeln(i,' => ',DayA[i]);
end;
{END}

writeln('');
writeln('Please enter month''s First Day from codelist');

readln(day); {Get current month from user}
writeln('');

{Error handeling for getting current day from user}
{START}
if (day < 0) OR (day >= 7)
then
begin
repeat
writeln('Please enter month''s First Day from codelist');

readln(day);
until ((day >= 0) AND (day <= 6));
fday := DayA[day];
writeln(fday);
end
else
begin
if ((day >= 0) AND (day <= 6))
then
begin
fday := DayA[day];
writeln(fday);
end
else
writeln('Please Enter Valid Charactor');
end;

{END}


firstdate:=1;






clrscr;


writeln(' Calander 2009');
writeln(' ',fmonth,'');
writeln('');
writeln(' Sun Mon Tue Wed Thu Fri Sat');
writeln('');
if(DayF[day]=0)
then
begin
space:=0;
end
else if(DayF[day]=1)
then
begin
space:=4;
end
else if(DayF[day]=2)
then
begin
space:=9;
end
else if(DayF[day]=3)
then
begin
space:=14;
end
else if(DayF[day]=4)
then
begin
space:=19;
end
else if(DayF[day]=5)
then
begin
space:=24;
end
else if(DayF[day]=6)
then
begin
space:=29;
end
else
begin
writeln('error');
end;

write('':space);
for date:=1 to monthtotal do
begin

write(date:6);

day:=day+1;
if(day>6)
then
begin
day:=0;
writeln('');
end;
end;



readln;
end.
[/code]
Sign In or Register to comment.