Saturday, September 3, 2016

Leap Year Checker in Delphi

A program that I wrote using Delphi programming language that will ask the user to give a year and then our program will check if the given year by the user is a leap year or not a leap year. The code is very simple because I am using a function in Delphi called IsLeapYear() to check if the given year is a leap year or not. I hope you will find my work useful. Thank you.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.
 
My mobile number here in the Philippines is 09173084360
.





Sample Program Output


Program Listing

leap.pas

unit leap;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Edit1: TEdit;
    Label3: TLabel;
    Button1: TButton;
    Label4: TLabel;
    Label5: TLabel;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

Var Given_Year : Integer;

procedure TForm1.Button1Click(Sender: TObject);
begin

Given_Year := StrToInt(Edit1.Text);

If IsLeapYear(Given_Year) Then
    Label3.Caption := 'The year ' + Edit1.Text + ' is a Leap Year.'
Else
   Label3.Caption :=  'The year ' + Edit1.Text + ' is not a Leap Year.'
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
Edit1.Text     := '';
Label3.Caption :='';
Edit1.Setfocus;
end;

end.



No comments:

Post a Comment