Friday, October 7, 2016

Absolute Value Solver in Delphi

A simple program that I wrote using Borland International Delphi 7 to solve the absolute value of the given negative integer number by the user. The code is very simple and easy to understand.


Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com. 


My email address are the following 
jakerpomperada@gmail.com and jakerpomperada@yahoo.com. 

My mobile number here in the Philippines is 09173084360.




Sample Program Output


Program Listing

unit abs;

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 value_a,solve_a : integer;

procedure TForm1.Button1Click(Sender: TObject);
begin
     value_a := StrToInt(Edit1.Text);
     solve_a := (-value_a);
     Label3.Caption := 'The absolute value of ' + edit1.text
                  + ' is ' + inttostr(solve_a) + '.';

end;

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

end.


No comments:

Post a Comment