prev PROGRAM EIGHTEEN
Write a program that prompts the user for todays date, a procedure using variable parameters which calculates tomorrows date, and the main program displaying tommorrows date.

Use records for todays date, tomorrows date, An array can be used to hold the days for each month of the year.

	Jan to Dec = 31,28,31,30,31,30,31,31,30,31,30,31
Remember to change the month or year as necessary.

	program PROG18 (input,output);   {date calculation program}
	type    date = record
	                 day, month, year : integer;
	               end;
	        datename = array[1..12] of integer;

	procedure update( var tomorrow : date; days_in_month : datename );
	begin
	     tomorrow.day := tomorrow.day + 1;                 {increment day}
	     if tomorrow.day > days_in_month[tomorrow.month] then
	     begin
	        tomorrow.day := 1;
	        tomorrow.month := tomorrow.month + 1;          {adjust month }
	        if tomorrow.month > 12 then                       {adjust year  }
	        begin
	          tomorrow.month := 1;
	          tomorrow.year := tomorrow.year + 1
	        end
	    end
	end; 

	var  todays_date : date;
	     days : datename;
	begin
	     days[1] := 31;  days[2] := 28;  days[3] := 31;  days[4] := 30;
	     days[5] := 31;  days[6] := 30;  days[7] := 31;  days[8] := 31;
	     days[9] := 30; days[10] := 31; days[11] := 30; days[12] := 31;

	     writeln('Enter todays date dd mm yy ');
	     readln( todays_date.day, todays_date.month, todays_date.year);
	     update( todays_date, days );
	     writeln('Tomorrows date will be ', todays_date.day,'-',
	              todays_date.month,'-',todays_date.year)
	end.


Copyright B Brown/P Henry/CIT, 1988-1997. All rights reserved.
prev