The George Washington University
School of Engineering and Applied Science
Department of Computer Science
CSci 51 -- Introduction to Software Development -- Spring 2001
Lab #4
For labs meeting on Feb. 8-9, 2001

The purpose of this exercise is to give you more practice developing an algorithm and using IF statements.  You can build up project 3 based on this exercise.

Part I. Writing an algorithm to see if a year is in the range of 1000 to 3000 and if it is a leap year or not.

Write an algorithm to solve the problem based on the following reference;
Leap Years
"The calendar year is 365 days long, unless the year is exactly divisible by 4, in which case an extra day is added to February to make the year 366 days long. If the year is the last year of a century, eg. 1700, 1800, 1900, 2000, then it is only a leap year if it is exactly divisible by 400. Therefore, 1900 wasn't a leap year but 2000 was. The reason for these rules is to bring the average length of the calendar year into line with the length of the Earth's orbit around the Sun, so that the seasons always occur during the same months each year."
source: http://www.rog.nmm.ac.uk/leaflets/leapyear/leapyear.html

Part II. Coding your algorithm

1. The input to your program is an integer.  The program will prompt the
user for an integer.

2. The output of the program is one of the following sentences;
The year,       your-input-integer, is out of range.
The year,       your-input-integer, is a leap year.
The year,       your-input-integer, is not a leap year.
The program should substitute 'your-input-integer' with the user's
input value.

Parts of the program are given below.

WITH Ada.Text_IO;
WITH Ada.Integer_Text_IO;
PROCEDURE lab_04 IS
  Year_Int : Positive;
BEGIN
  Ada.Text_IO.Put (Item => "Please enter a year: ");
  Ada.Integer_Text_IO.Get (Item => Year_Int);
  ---
  ---
  Ada.Text_IO.Put (Item => " The year, ");
  Ada.Integer_Text_IO.Put (Item => Year_Int, Width=>1);
  Ada.Text_IO.Put (Item => ", is out of range");
  ---
  ---
END lab_04;
You may need to use REM to get a remainder from integer division.  Refer to page 98 in the textbook for more information.