Tip on using array:
Code:
var
monthNames: array[1..12] of string = ('January','February','March','April','May','June','July','August','September','October','November','December');
... In the main program where you go through months in a loop:
repeat
menu;
...
clrscr;
if (month > 0) and (month <= 12) then
writeln(monthNames[month],'!'+#13); // #13 is a line change character
case month of
12,1,2: wint;
3,4: spri;
5..8: sumr;
9..11: autm;
end;
until month = 0;
Also in this code etc:
Code:
procedure autm;
begin
autumn:=(month>8) and (month<=11);
You don't need to check if it is autumn, it will always be true because you only call this procedure it in that case.
You can delete all these variables (autumn,winter,spring,summer:boolean; )
Still want to fix the indent on teacher's code It is very important that the code is understandable. Sometimes wrong indent makes programmer think that part of code belongs inside IF/Else structure when it doesn't.
Code:
summer:= (month > 5) and (month <=8);
if summer then
writeln('Melon')
else
writeln('Oysters');
write('Roast Chicken with ');
if summer then
writeln('Green Salad')
else
writeln('Two Veg');
Bookmarks