Delphi

Stian Søiland, IT 111, øvingsgruppe 15 (stud.ass. Kari Alvheim)

Delphi - Øving 3 - Oppgave 3

Oppgave 3, bilde 1 Oppgave 3, bilde 2

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    tkonvertert: TEdit;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);

const fot_i_tommer=12;
      tomme_i_cm=2.54;

function konverter(meter:real):string;
 var fot,tomme:real;

 begin
  tomme := meter * 100 / tomme_i_cm;
  fot := Int(tomme / fot_i_tommer);
  tomme := tomme - fot * fot_i_tommer;
  if tomme >= 0.5 then tomme := int(tomme)+1
   else tomme := int(tomme);
  konverter := FloatToStr(Fot) + ''' ' + FloatToStr(Tomme) + '"'
 end;

begin
 tkonvertert.text :=
  konverter(
   StrToFloat(
    InputBox('Lengde','Skriv lengde i meter','')
   )
  );
end;

end.
  

 


© Stian Søiland 1998

Valid HTML 4.0!