Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit UnitProgressao;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
- Dialogs, StdCtrls, ExtCtrls, Math;
- type
- TForm1 = class(TForm)
- Label1: TLabel;
- Label2: TLabel;
- Label3: TLabel;
- Edit1: TEdit;
- Edit2: TEdit;
- Edit3: TEdit;
- PaButton: TButton;
- PgButton: TButton;
- Panel1: TPanel;
- procedure PaButtonClick(Sender: TObject);
- procedure PgButtonClick(Sender: TObject);
- private
- { Private declarations }
- public
- { Public declarations }
- end;
- var
- Form1: TForm1;
- Razao: Real;
- an, a1, Tdesejado: Real;
- potencia: Double;
- implementation
- {$R *.dfm}
- { an=a1+(n-1)*R
- an: Termo desejado
- n-1: Termodesejado menos 1
- R: Razão }
- procedure TForm1.PaButtonClick(Sender: TObject);
- begin
- Form1.Caption:='Progessão Aritimetica';
- a1:=StrToFloat(Edit1.Text);
- Razao:=StrToFloat(Edit2.Text);
- Tdesejado:=strToFloat(Edit3.Text);
- an:=a1+(Tdesejado-1)*Razao;
- Panel1.Caption:=FloatToStr(an);
- end;
- procedure TForm1.PgButtonClick(Sender: TObject);
- begin //num=a1*(razao)^(n-1);
- Form1.Caption:='Progressão geometrica';
- a1:=StrToFloat(Edit1.Text);
- Razao:=StrToFloat(Edit2.Text);
- Tdesejado:=strToFloat(Edit3.Text);
- //caslculo da pg
- Tdesejado:=Tdesejado-1;
- potencia:=POWER(Razao, Tdesejado);
- an:=a1*potencia;
- Panel1.Caption:=FloatTostr(an);
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement