i am a beginner in pascal program. i tried to make a calendar in pascal but the output is not what i looking for. when i run it, on Mar the program. in March, the first and second weeks of the program went well. but in the following week the program did not run as it should
………………
program tgs8_1;
uses crt;
type
hari1pekan=(ahad,senin,selasa,rabu,kamis,jumat,sabtu);
month=(jan,feb,mar,apr,mei,jun,jul,agu,sep,okt,nov,des);
var
awalbulan,i:hari1pekan;
bulan:month;
tahun,lebar,x,y,j:integer;
begin
clrscr;
write('Hari pertama bulan Januari: ');
readln(awalbulan);
write('Tahun: ');
readln(tahun);
lebar:=7;
x:=ord(awalbulan);
y:=5;
for bulan:=jan to des do
begin
gotoxy(1,y);
write(bulan,' ',tahun);
gotoxy(1,y+1);
for i:=ahad to sabtu do
begin
write(i:lebar);
end;
y:=y+2;
if(bulan=jan)or(bulan=mar)or(bulan=mei)or(bulan=jul)or(bulan=agu)or(bulan=okt)or(bulan=des) then
begin
for j:=1 to 31 do
begin
if x=7 then
begin
x:=0;
y:=y+1;
end;
gotoxy(lebar*x+1,y);write(j:3);
x:=x+1;
end;
y:=y+2;
end
else
if(bulan=feb) then
begin
if(tahun mod 4=0) then
begin
for j:=1 to 29 do
begin
if x=7 then
begin
x:=0;
y:=y+1;
end;
gotoxy(lebar*x+1,y);write(j:3);
x:=x+1;
end;
y:=y+2;
end
else
begin
for j:=1 to 28 do
begin
if x=7 then
begin
x:=0;
y:=y+1;
end;
gotoxy(lebar*x+1,y);write(j:3);
x:=x+1;
end;
y:=y+2;
end;
end
else
begin
for j:=1 to 30 do
begin
if x=7 then
begin
x:=0;
y:=y+1;
end;
gotoxy(lebar*x+1,y);write(j:3);
x:=x+1;
end;
y:=y+2;
end;
end;
readln;
end.
……………..
What error is there in the program so that the output looks like:
pascal calendar program
eyes corner is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.