Mam taki sobie program zrobiony w Delphi tryb wizualny liczący średnią ocen i muszę do niego dorobić możliwość pokazania na końcu ile wpisanych zostało ocen. Np 2 x 3 4 x 2 i ile to procent wszystkich ocen.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Button1: TButton;
Label2: TLabel;
Label3: TLabel;
procedure FormCreate(Sender: TObject);
procedure Edit1Change(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
Suma, Licznik : Integer;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Edit1.text := ''; {wyczyszczenie komonentu edit1}
Suma := 0;
Licznik := 0;
end;
procedure TForm1.Edit1Change(Sender: TObject);
begin
Edit1.Color := clWindow; //ustawienie bialego koloru tla dla komonentu edit
if (Trim(Edit1.Text) <> '') then begin
if (StrToIntDef(Edit1.Text,-1) < 0) then Edit1.Color := clRed;
{jezeli wartosc jest mniejsza od zera ustaw tlo na czerwony}
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var liczba :ShortInt; //zadeklarowanie zmiennej liczbowej calkowitej
begin
liczba := 0; //wyzerowanie zmiennej
if (Edit1.Color = clWindow) then begin
//jezeli kolor komponentu edit1 bedzie bialy to wykonaj ponizsze instrukcje
liczba := StrToInt(Edit1.text);
if ((liczba>0) and (liczba <7 )) then begin
Suma := Suma + liczba;
Licznik := Licznik + 1;
Label2.Caption := 'suma wynosi: ' + IntToStr(Suma);
Label3.Caption := 'ilosc podanych ocen: ' + IntToStr(Licznik);
end;
end;
end;
end.
Czyli muszę dodać nowy label?
Czy da się wykorzystać ten patent?
if o1>0 then writeln(o1,' x 1', o1*100/n:10:2,'%');
if o2>0 then writeln(o2,' x 2', o2*100/n:10:2,'%');
if o3>0 then writeln(o3,' x 3', o3*100/n:10:2,'%');
if o4>0 then writeln(o4,' x 4', o4*100/n:10:2,'%');
if o5>0 then writeln(o5,' x 5', o5*100/n:10:2,'%');
if o6>0 then writeln(o6,' x 6', o6*100/n:10:2,'%');