Forum www.til2010.fora.pl Strona Główna
 FAQ   Szukaj   Użytkownicy   Grupy    Galerie   Rejestracja   Profil   Zaloguj się, by sprawdzić wiadomości   Zaloguj 

kalkulator w B1

 
Napisz nowy temat   Odpowiedz do tematu    Forum www.til2010.fora.pl Strona Główna -> II rok 2011/2012 / Semestr III / INFORMATYKA
Zobacz poprzedni temat :: Zobacz następny temat  
Autor Wiadomość
Asia




Dołączył: 14 Paź 2010
Posty: 92
Przeczytał: 0 tematów

Skąd: Grudziądz

PostWysłany: Pią 19:56, 28 Paź 2011    Temat postu: kalkulator w B1

unit U70310;

interface

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

type
TForm7 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Panel1: TPanel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form7: TForm7;

implementation

{$R *.dfm}

procedure TForm7.Button1Click(Sender: TObject);
var
x,y,z:smallint;
niepoprawny:boolean;
begin
try
x:=strtoint(edit1.text);
except
x:=0;
edit1.Text:='0'
end;
try
y:=strtoint(edit2.text);
except
y:=0;
edit2.Text:='0'
end;
z:=x+y;
panel1.caption:='suma='+inttostr(z);
niepoprawny:=(sign(x)=sign(y))AND(sign(z)<>sign(x));
if niepoprawny then panel1.caption:='wynik niepoprawny'
else
panel1.Caption:='suma='+inttostr(z);
end;

procedure TForm7.Button2Click(Sender: TObject);
var
x,y,z:smallint;
niepoprawny:boolean;
begin
x:=strtoint(edit1.Text);
y:=strtoint(edit2.Text);
z:=x-y;
panel1.Caption:='różnica='+inttostr(z);
niepoprawny:=(sign(y)=sign(z))AND(sign(x)<>sign(y));
if niepoprawny then panel1.caption:='wynik niepoprawny'
else
panel1.Caption:='różnica='+inttostr(z);
end;

procedure TForm7.Button3Click(Sender: TObject);
var
x,y,z:smallint;
niepoprawny:boolean;
begin
x:=strtoint(edit1.Text);
y:=strtoint(edit2.Text);
z:=x*y;
panel1.Caption:='iloczyn='+inttostr(z);
niepoprawny:=((sign(x)=sign(y))AND(z<0)) or ((sign(x)<>sign(y))AND(z>0));
if niepoprawny then panel1.caption:='wynik niepoprawny'
else
panel1.Caption:='iloczyn='+inttostr(z);
end;

procedure TForm7.Button4Click(Sender: TObject);
var
x,y:smallint;
z:single;
begin
x:=strtoint(edit1.Text);
y:=strtoint(edit2.Text);
z:=x/y;
panel1.Caption:='iloraz='+ floattostr(z);

end;

procedure TForm7.Button5Click(Sender: TObject);
var
x,y,z,reszta:smallint;
begin
x:=strtoint(edit1.Text);
y:=strtoint(edit2.Text);
z:=x div y;
reszta:=x mod y;
panel1.Caption:='iloraz='+ floattostr(z) + ' reszta'+ floattostr(reszta);

end;

end.
Powrót do góry
Zobacz profil autora
Wyświetl posty z ostatnich:   
Napisz nowy temat   Odpowiedz do tematu    Forum www.til2010.fora.pl Strona Główna -> II rok 2011/2012 / Semestr III / INFORMATYKA Wszystkie czasy w strefie CET (Europa)
Strona 1 z 1

 
Skocz do:  
Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach


fora.pl - załóż własne forum dyskusyjne za darmo
Powered by phpBB © 2001, 2005 phpBB Group

Theme xand created by spleen & Programosy.
Regulamin