Advertisement
jacob_segundo

Pa e Pg

Oct 28th, 2021
467
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.37 KB | None | 0 0
  1. unit UnitProgressao;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  7.   Dialogs, StdCtrls, ExtCtrls, Math;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Label1: TLabel;
  12.     Label2: TLabel;
  13.     Label3: TLabel;
  14.     Edit1: TEdit;
  15.     Edit2: TEdit;
  16.     Edit3: TEdit;
  17.     PaButton: TButton;
  18.     PgButton: TButton;
  19.     Panel1: TPanel;
  20.     procedure PaButtonClick(Sender: TObject);
  21.     procedure PgButtonClick(Sender: TObject);
  22.   private
  23.     { Private declarations }
  24.   public
  25.     { Public declarations }
  26.   end;
  27.  
  28. var
  29.   Form1: TForm1;
  30.    Razao: Real;
  31.    an, a1, Tdesejado: Real;
  32.    potencia: Double;
  33. implementation
  34.  
  35. {$R *.dfm}
  36.  
  37.  
  38. { an=a1+(n-1)*R
  39. an: Termo desejado
  40. n-1: Termodesejado menos 1
  41. R: Razão   }
  42. procedure TForm1.PaButtonClick(Sender: TObject);
  43. begin
  44. Form1.Caption:='Progessão Aritimetica';
  45. a1:=StrToFloat(Edit1.Text);
  46. Razao:=StrToFloat(Edit2.Text);
  47. Tdesejado:=strToFloat(Edit3.Text);
  48. an:=a1+(Tdesejado-1)*Razao;
  49. Panel1.Caption:=FloatToStr(an);
  50. end;
  51.  
  52. procedure TForm1.PgButtonClick(Sender: TObject);
  53. begin   //num=a1*(razao)^(n-1);
  54. Form1.Caption:='Progressão geometrica';
  55. a1:=StrToFloat(Edit1.Text);
  56. Razao:=StrToFloat(Edit2.Text);
  57. Tdesejado:=strToFloat(Edit3.Text);
  58. //caslculo da pg
  59. Tdesejado:=Tdesejado-1;
  60. potencia:=POWER(Razao, Tdesejado);
  61. an:=a1*potencia;
  62. Panel1.Caption:=FloatTostr(an);
  63. end;
  64.  
  65. end.
  66.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement