Инженерный калькулятор

Автор работы: Пользователь скрыл имя, 11 Марта 2013 в 23:18, курсовая работа

Краткое описание

Эволюция технических средств персональных компьютеров привела к повсеместному вытеснению старой “доброй” ОС MS-DOS значительно более мощными системами Windows, программирование для которых существенно сложнее, чем программирование для MS-DOS. В 1993 году Microsoft выпустила первую визуальную среду программирования Visual Basic, и программирование для Windows стало даже проще, чем программирование для MS-DOS. В ответ на это Borland в 1995 году выпустила первую версию Delphi, а затем, с интервалом в 1 год, - еще 4 версии: 2, 3, 4 и 5. Наконец, в середине 2001 г. выпускается версия 6.

Содержание

Введение………………………………………………………………………..…..5
Теоретическая часть……………………………………………………………...10
Описание функций и процедур……………………………………………….....13
Руководство пользователя…………………………………………………….…17
Результат работы программы……………………………………………….…...24
Заключение………………………………………………………………….…….26
Список литературы……

Вложенные файлы: 1 файл

Работа.docx

— 1.65 Мб (Скачать файл)

     memo1.Text:=Format('%x',[c3]);

   end;

end;

 

procedure TForm1.SpeedButtonOrClick(Sender: TObject);

begin

flag:=true;  klav:='i';

 

  case ss of

      2:  memo1.Text:=inttostr((Rto10(memo1.text,2)));

      8:  memo1.Text:=inttostr((Rto10(memo1.text,8)));

     16: memo1.Text:=inttostr((Rto10(memo1.text,16)));

   end;

 

     if mok=0 then   mo:=strtoint(memo1.Text);

     if (mok=1) then   mb1:=strtoint(memo1.text);

     if (mok>=1) then memo1.Text:=inttostr(mo or mb1);

    R:=strtofloat(memo1.Text);

 

   case ss  of

      2:  memo1.Text:=(ConvertToCs(strtoint(memo1.Text),2));

      8:  memo1.Text:=(ConvertToCs(strtoint(memo1.Text),8));

      16:  memo1.Text:=(ConvertToCs(strtoint(memo1.Text),16));

    end;

    kol:=1; inc(mok);

end;

 

procedure TForm1.SpeedButtonPiClick(Sender: TObject);

begin

memo1.Text:=floattostr(pi);

flag:=true;

end;

 

procedure TForm1.SpeedButtonPlusDblClick(Sender: TObject);

begin

  flag:=true;

  memo1.Text:=floattostr(strtofloat(memo1.text)+a);

end;

 

procedure TForm1.SpeedButtonPlusMinusClick(Sender: TObject);

begin

  if strtofloat(memo1.text)>0 then

      memo1.Text:=floattostr(strtofloat(memo1.text)*-1)

  else

   if strtofloat(memo1.text)<0 then

      memo1.Text:=floattostr(strtofloat(memo1.text)*-1)

end;

 

procedure TForm1.SpeedButtonPlusMinusMouseLeave(Sender: TObject);

begin

  SpeedButtonPlusMinus.Font.Color:=clBlack;

end;

 

procedure TForm1.SpeedButtonPlusMinusMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);

begin

  SpeedButtonPlusMinus.Font.Color:=clred;

end;

 

procedure TForm1.SpeedButtonRavnoClick(Sender: TObject);

var j:integer;

begin

   case klav of

   'p': begin

          SpeedButtonPlusClick(SpeedButtonPlus);

          pk:=1; a:=0; m:=r; d:=r; u:=r;

        end;

   'm': begin

          SpeedButtonMinusClick(SpeedButtonMinus);

          mk:=0; a:=0; m:=r; d:=r; u:=r;

        end;

   'd': begin

          SpeedButtonDelClick(SpeedButtonDel);

          dk:=0; a:=0; m:=r; d:=r; u:=r;

        end;

   'u': begin

          SpeedButtonUmnClick(SpeedButtonUmn);

          uk:=0; a:=0; m:=r; d:=r; u:=r;

        end;

   '^': memo1.Text:=floattostr(IntPower(s,strtoint(memo1.text)));

   'o': begin

        SpeedButtonModClick(SpeedButtonMod);

        mo:=0; mok:=0;

        end;

   'a': begin

          SpeedButtonAndClick(SpeedButtonAnd);

          mo:=0; mok:=0;

        end;

   'i': begin

        SpeedButtonOrClick(SpeedButtonOr);

        mo:=0; mok:=0;

        end;

   'x': begin

          SpeedButtonXorClick(SpeedButtonXor);

          mo:=0; mok:=0;

        end;

   'l': begin

          SpeedButtonLshClick(SpeedButtonLsh);

          ls:=0; lk:=0;

        end;

  End;

flag:=true;     klav:='r';

end;

 

procedure TForm1.SpeedButtonRavnoMouseLeave(Sender: TObject);

begin

  SpeedButtonRavno.Font.Color:=clblack;

end;

 

procedure TForm1.SpeedButtonRavnoMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);

begin

  SpeedButtonRavno.Font.Color:=clred;

end;

 

procedure TForm1.SpeedButtonSClick(Sender: TObject);

var

  sum,n:extended; index:integer;

begin

sum:=0;  n:=0;

for index:=0 to (form2.ListBox1.Items.Count-1) do

  begin

    sum:=sum+strtofloat(form2.ListBox1.Items.Strings[index]);

  end;

    try

      sum:=sum/(form2.ListBox1.Items.Count);

    except

      memo1.Text:='0';

    end;

 

  for index:=0 to (form2.ListBox1.Items.Count-1) do

  begin

    n:=n+sqr(strtofloat(form2.ListBox1.Items.Strings[index])-sum);

  end;

if inv.Checked=true then

   try memo1.Text:=floattostr(power((n/form2.ListBox1.Count),1/2))

   except memo1.Text:='0'; end

else

   try memo1.Text:=floattostr(sqrt(n/(form2.ListBox1.Items.Count-1)))

   except memo1.Text:='0'; end;

Flag:=true;

end;

 

procedure TForm1.SpeedButtonSinClick(Sender: TObject);

var t:real;

begin

  t:=strtofloat(memo1.Text);

{---------------------------радианы---begin---------------------------------}

   if RadioButtonRad.Checked=true then BEGIN

 

   if (Inv.Checked=false) and (Hyp.Checked=false) then

   memo1.Text:=floattostr(sin(strtofloat(memo1.text))) ;

 

      if (Inv.Checked=true) and (Hyp.Checked=false) then begin

    if ((strtofloat(memo1.Text)<=1) and (strtofloat(memo1.Text)>=(-1)) ) then

   memo1.Text:=floattostr(Arcsin(strtofloat(memo1.text)))

    else

     memo1.Text:=net; end;

 

  if (Inv.Checked=false) and (Hyp.Checked=true) then

   memo1.Text:=floattostr(sinh(t));

 

   if (Inv.Checked=true) and (Hyp.Checked=true) then

   memo1.Text:=floattostr(Arcsinh(strtofloat(memo1.text)));

                                        END;

{---------------------------радианы---end-------------------------------------}

 

{---------------------------градусы---begin-----------------------------------}

  if RadioButtonGradus.Checked=true then

BEGIN

     if (strtofloat(memo1.Text)=180) then begin memo1.Text:='0'; end;

  if (Inv.Checked=false) and (Hyp.Checked=false) then

  memo1.text:=floattostr(sin(DegToRad(strtofloat(memo1.text))));

 

  if (Inv.Checked=true) and (Hyp.Checked=true) then

  memo1.text:=floattostr(Arcsinh(strtofloat(memo1.text)));

 

  if (Inv.Checked=true) and (Hyp.Checked=false) then begin

  if ((strtofloat(memo1.Text)<=1) and (strtofloat(memo1.Text)>=(-1)) ) then

   memo1.Text:=floattostr(180/pi*Arcsin(strtofloat(memo1.text)))

else memo1.Text:=net;  end;

 

  if (Inv.Checked=false) and (Hyp.Checked=true) then

     memo1.text:=floattostr(sinh(strtofloat(memo1.text)));

 

  if (Inv.Checked=false) and (Hyp.Checked=false) then

  Begin

    if (trunc(strtofloat(memo1.Text))=0)  then begin memo1.Text:='0';  end;

    if (trunc(strtofloat(memo1.Text))=90) then begin memo1.Text:='1'; end;

    if (strtofloat(memo1.Text)=270) then begin memo1.Text:='-1'; end;

    if (strtofloat(memo1.Text)=180) then begin memo1.Text:='0'; end;

    if (strtofloat(memo1.Text)=360) then begin memo1.text:='0'; end;

  End;

END;

{---------------------------градусы___end--------------------------------------}

 

{---------------------------грады__begin--------------------------------------}

 

if RadioButtonGrad.Checked=true then

BEGIN

 

if (Inv.Checked=false) and (Hyp.Checked=false) then

  memo1.text:=floattostr(sin(gradtorad(strtofloat(memo1.text))));

 

  if (Inv.Checked=true) and (Hyp.Checked=false) then begin

  if ((strtofloat(memo1.Text)<=1) and (strtofloat(memo1.Text)>=(-1)) ) then

   memo1.Text:=floattostr(200/pi*Arcsin(strtofloat(memo1.text)))

else memo1.Text:=net;  end;

 

  if (Inv.Checked=false) and (Hyp.Checked=true) then

     memo1.text:=floattostr(sinh(strtofloat(memo1.text)));

 

   if (Inv.Checked=true) and (Hyp.Checked=true) then

  memo1.text:=floattostr(Arcsinh(strtofloat(memo1.text)));

 

END;

{---------------------------грады___end----------------------------------------}

flag:=true;

end;

 

procedure TForm1.SpeedButtonSqrtClick(Sender: TObject);

begin

flag:=true;

try

memo1.Text:=floattostr(sqrt(strtofloat(memo1.Text)));

except

   memo1.Text:=net;

end;

end;

 

procedure TForm1.SpeedButtonStaClick(Sender: TObject);

begin

  AnimateWindow(form2.Handle, 90, aw_blend);

  Form2.Show;

  SpeedButtonS.Enabled:=true;

  SpeedButtonSum.Enabled:=true;

  SpeedButtonAve.Enabled:=true;

  SpeedButtonDat.Enabled:=true;

end;

 

procedure TForm1.SpeedButtonSumClick(Sender: TObject);

var sum:real; si:integer;

begin

  sum:=0;

    for si := 0 to (Form2.ListBox1.Items.Count-1) do

      sum:=sum+strtofloat(form2.ListBox1.Items.Strings[si]);

    memo1.Text:=floattostr(sum);

end;

 

procedure TForm1.SpeedButtonTClick(Sender: TObject);

var k:integer;

begin

nol:='z';   k:=0;

    for i := 1 to length(memo1.text) do

      if memo1.Text[i]=',' then inc(k);

  if k=0 then memo1.Text:=memo1.Text+',';

flag:=false;

end;

 

procedure TForm1.SpeedButtonTgClick(Sender: TObject);

var t:real;

begin

TRY

  t:=strtofloat(memo1.Text);

{---------------------------радианы---begin-----------------------------------}

  if  RadioButtonRad.Checked=true then

BEGIN

   if (Inv.Checked=false) and (Hyp.Checked=false) then

   memo1.Text:=floattostr(tan(strtofloat(memo1.text))) ;

 

      if (Inv.Checked=true) and (Hyp.Checked=false) then begin

    if ((strtofloat(memo1.Text)<90) and (strtofloat(memo1.Text)>(-90)) ) then

   memo1.Text:=floattostr(Arctan(strtofloat(memo1.text)))

    else

     memo1.Text:=net; end;

 

  if (Inv.Checked=false) and (Hyp.Checked=true) then

   memo1.Text:=floattostr(tanh(t));

 

   if (Inv.Checked=true) and (Hyp.Checked=true) then  begin

    if ((strtofloat(memo1.Text)<=1) and (strtofloat(memo1.Text)>=(-1)) ) then

   memo1.Text:=floattostr(Arctanh(strtofloat(memo1.text)))

   else memo1.Text:=net; end;

END;

{---------------------------радианы___end-------------------------------------}

 

{---------------------------градусы___begin-----------------------------------}

    if radiobuttonGradus.Checked=true then

BEGIN

   if  ((inv.Checked=true) and (hyp.Checked=false))then

     memo1.Text:=floattostr(180/pi*Arctan(strtofloat(memo1.Text)));

 

  if ((inv.Checked=true) and (hyp.Checked=true)) then   begin

   if (strtofloat(memo1.Text)<1) then

    memo1.Text:=floattostr(ArcTanH(strtofloat(memo1.text)))

   else  begin

    memo1.Text:=net; exit;  end;

    end ;

 

  if ((inv.Checked=false) and ( hyp.Checked=true)) then

   memo1.Text:=floattostr(tanh(strtofloat(memo1.Text)));

 

  if ((inv.Checked=false) and ( hyp.Checked=false)) then  Begin

if (strtofloat(memo1.Text)=0)  then  memo1.Text:='0';

if (strtofloat(memo1.Text)=90) then  memo1.Text:=net;

if (strtofloat(memo1.Text)=270) then  memo1.Text:=net;

if (strtofloat(memo1.Text)=180) then  memo1.Text:='0';

if (strtofloat(memo1.Text)=360) then  memo1.text:='0';

   if ((strtofloat(memo1.Text)=90 ) or (strtofloat(memo1.Text)=(-90)) ) then

  begin

   memo1.Text:=net;

    inv.Checked:=false;

    hyp.Checked:=false;    exit;  end

   else memo1.Text:=floattostr(DegToRad(strtofloat(memo1.text))) ;

   end;

END;

{---------------------------градусы___end-----------------------------------}

 

{---------------------------грады__begin--------------------------------------}

 

if RadioButtonGrad.Checked=true then

BEGIN

 

if  ((inv.Checked=true) and (hyp.Checked=false))then

   memo1.Text:=floattostr(200/pi*Arctan(strtofloat(memo1.Text)));

 

 

  if ((inv.Checked=true) and (hyp.Checked=true)) then begin

    if strtofloat(memo1.text)>1 then memo1.Text:=net else

   memo1.Text:=floattostr(ArcTanH(strtofloat(memo1.Text))); end;

 

  if ((inv.Checked=false) and ( hyp.Checked=true)) then

  memo1.Text:=floattostr(Tanh(strtofloat(memo1.Text)));

 

if ((inv.Checked=false) and ( hyp.Checked=false)) then

memo1.Text:=floattostr(tan(gradtorad(strtofloat(memo1.Text))));

 

END;

{---------------------------грады__end--------------------------------------}

Except

END;

flag:=true;

end;

 

procedure TForm1.SpeedButtonTMouseLeave(Sender: TObject);

begin

  SpeedButtonT.Font.Color:=clBlack;

end;

 

procedure TForm1.SpeedButtonTMouseMove(Sender: TObject; Shift: TShiftState; X,Y: Integer);

begin

  SpeedButtonT.Font.Color:=clred;

end;

 

procedure TForm1.SpeedButtonUmnClick(Sender: TObject);

begin

 

   case ss of

      2:  memo1.Text:=inttostr((Rto10(memo1.text,2)));

      8:  memo1.Text:=inttostr((Rto10(memo1.text,8)));

     16: memo1.Text:=inttostr((Rto10(memo1.text,16)));

   end;

 

if kol=1 then

BEGIN

  if (klav='m') then

    begin

      memo1.Text:=floattostr((r-strtofloat(memo1.text)));

      R:=0; pk:=0; mk:=0; dk:=0; uk:=0;

    end;

 

    if (klav='p') then

    begin

      memo1.Text:=floattostr(r+strtofloat(memo1.Text));

      R:=0; pk:=0; mk:=0; dk:=0; uk:=0;

    end;

 

     if (klav='d') then

     begin

      memo1.Text:=floattostr(r/strtofloat(memo1.text));

      R:=0; pk:=0; mk:=0; dk:=0; uk:=0;

     end;

 

     if (klav='o') then SpeedButtonModClick(SpeedButtonMod);

     if (klav='l') then SpeedButtonLshClick(SpeedButtonLsh);

 

    flag:=true;

    if uk=0 then u:=strtofloat(memo1.Text);

    if uk=1 then R:=u*strtofloat(memo1.text);

    if uk>1 then R:=R*strtofloat(memo1.Text);

    if uk>=1 then memo1.Text:=floattostr(r);

    R:=strtofloat(memo1.Text);

 

    case ss  of

      2:  memo1.Text:=(ConvertToCs(strtoint(memo1.Text),2));

      8:  memo1.Text:=(ConvertToCs(strtoint(memo1.Text),8));

      16:  memo1.Text:=(ConvertToCs(strtoint(memo1.Text),16));

    end;

 

END;

kol:=0; klav:='u';  inc(uk);

end;

 

procedure TForm1.SpeedButtonX2Click(Sender: TObject);

begin

  memo1.Text:=floattostr(strtofloat(memo1.text)*strtofloat(memo1.text));

end;

 

procedure TForm1.SpeedButtonXorClick(Sender: TObject);

begin

flag:=true;  klav:='x';

case ss of

      2:  memo1.Text:=inttostr((Rto10(memo1.text,2)));

      8:  memo1.Text:=inttostr((Rto10(memo1.text,8)));

     16: memo1.Text:=inttostr((Rto10(memo1.text,16)));

   end;

 

     if mok=0 then mo:=strtoint(memo1.Text);

      if (mok=1) then  mb1:=strtoint(memo1.text);

     if (mok>=1) then memo1.Text:=inttostr(mo xor mb1);

    R:=strtofloat(memo1.Text);

 

   case ss  of

      2:  memo1.Text:=(ConvertToCs(strtoint(memo1.Text),2));

      8:  memo1.Text:=(ConvertToCs(strtoint(memo1.Text),8));

      16:  memo1.Text:=(ConvertToCs(strtoint(memo1.Text),16));

    end;

    kol:=1; inc(mok);

end;

 

procedure TForm1.SpeedButtonXYClick(Sender: TObject);

begin

   klav:='^';

   flag:=true;  l:=l+1;

   s:=strtofloat(memo1.Text);

end;

 

procedure TForm1.StandartClick(Sender: TObject);

begin

Form5.Show;

Form1.hide;

end;

 

END.  {END}

 

{---------------------------------------------------------------------------------}

UNIT 2

 

unit Unit2;

 

interface

 

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, Buttons, StdCtrls, jpeg, ExtCtrls, XPMan;

 

type

  TForm2 = class(TForm)

    ListBox1: TListBox;

    SpeedButtonRet: TSpeedButton;

    SpeedButtonLoad: TSpeedButton;

    SpeedButtonCd: TSpeedButton;

    SpeedButtonCad: TSpeedButton;

    LabelN: TLabel;

    Image1: TImage;

    XPManifest1: TXPManifest;

    procedure FormClose(Sender: TObject; var Action: TCloseAction);

    procedure SpeedButtonRetClick(Sender: TObject);

    procedure SpeedButtonCadClick(Sender: TObject);

    procedure SpeedButtonCdClick(Sender: TObject);

    procedure SpeedButtonLoadClick(Sender: TObject);

    function ListBox1DataFind(Control: TWinControl;

      FindString: string): Integer;

  private

    { Private declarations }

  public

    { Public declarations }

  end;

 

var

  Form2: TForm2;

 

implementation

 

{$R *.dfm}

uses unit1;

 

  procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);

begin

  form1.SpeedButtonS.Enabled:=false;

  form1.SpeedButtonSum.Enabled:=false;

  form1.SpeedButtonAve.Enabled:=false;

  form1.SpeedButtonDat.Enabled:=false;

end;

 

function TForm2.ListBox1DataFind(Control: TWinControl; FindString: string): Integer;

begin

  labeln.Caption:=inttostr(ListBox1.Items.Count);

end;

 

procedure TForm2.SpeedButtonCadClick(Sender: TObject);

begin

  ListBox1.Clear;

  labeln.Caption:='n= '+inttostr(ListBox1.Items.Count);

end;

 

procedure TForm2.SpeedButtonCdClick(Sender: TObject);

begin

  ListBox1.Items.Delete(Listbox1.ItemIndex);

  labeln.Caption:='n= '+inttostr(ListBox1.Items.Count);

end;

 

procedure TForm2.SpeedButtonLoadClick(Sender: TObject);

begin

try

  form1.Memo1.Text:=Listbox1.Items.Strings[ListBox1.ItemIndex];

except

end;

end;

 

procedure TForm2.SpeedButtonRetClick(Sender: TObject);

begin

  Form1.SetFocus;

  labeln.Caption:='n= '+inttostr(ListBox1.Items.Count);

end;

 

end.

 

{---------------------------------------------------------------------------------}

 

unit Unit3;

 

interface

 

uses

  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,

  Dialogs, Grids, StdCtrls, unit5;

 

type

  TForm3 = class(TForm)

    StringGrid1: TStringGrid;

    Label1: TLabel;

    Button1: TButton;

    Label2: TLabel;

    Label3: TLabel;

    Label4: TLabel;

    Label5: TLabel;

    Label6: TLabel;

    Label7: TLabel;

    procedure FormCreate(Sender: TObject);

    procedure Button2Click(Sender: TObject);

    procedure Button1Click(Sender: TObject);

  private

    { Private declarations }

  public

 

  end;

 

var

  Form3: TForm3;  R:real; i,j,k,l,n:integer;

 

implementation

 

{$R *.dfm}

 

procedure TForm3.Button1Click(Sender: TObject);

var

       a:array [0..8,0..8] of real;  x:array [0..6] of real;

       c2,s:real; m:integer;

begin

R:=0; n:=StringGrid1.RowCount;

for i := 0 to StringGrid1.RowCount-1 do

  for j := 0 to StringGrid1.ColCount-1 do

    a[j,i]:=strtofloat(StringGrid1.Cells[j,i]);

 

  for i:=0 to n-2 do

  begin

    c2:=a[i,i];

      for j:=i to n+1 do a[j,i]:=a[j,i]/c2;

 

      for k:=i+1 to n do

      for j:=i+1 to n+1 do

       a[k,j]:=a[k,j]-a[k,i]*a[i,j];

  end;

 

  for i := 0 to StringGrid1.RowCount-1 do

  for j := 0 to StringGrid1.ColCount-1 do begin

     form5.StringGrid1.Cells[j,i]:=floattostr(a[j,i]); end;

     for i:=0 to 6 do x[i]:=0;

 

  x[n-1]:=a[n,n-1]/a[n-1,n-1];

  n:=n-1;

  k:=n-1;

  s:=0;

  m:=k-2;

  repeat

   s:=0;

   for j:=m to n do s:=s+a[j,k]*x[j];

   x[k]:=a[n+1,k]-s;

Информация о работе Инженерный калькулятор