Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program laz;
- {$mode objfpc}{$H+}
- uses
- {$IFDEF UNIX}{$IFDEF UseCThreads}
- cthreads,
- {$ENDIF}{$ENDIF}
- Classes, SysUtils, CustApp
- { you can add units after this };
- type
- { TMyApplication }
- TMyApplication = class(TCustomApplication)
- protected
- procedure DoRun; override;
- public
- constructor Create(TheOwner: TComponent); override;
- destructor Destroy; override;
- procedure WriteHelp; virtual;
- end;
- { TMyApplication }
- procedure TMyApplication.DoRun;
- var
- ErrorMsg: String;
- H, L, B, V, A, T, i,j , vx,vy,g,x,y,u: Real;
- f:text;
- abc,cba:String;
- begin
- // quick check parameters
- ErrorMsg:=CheckOptions('h', 'help');
- g:=10;
- system.assign(f, 'dane.csv');
- rewrite(f);
- writeLn('write value H, coordinate of the starting point');
- begin
- repeat
- Readln(H);
- if H<0 then
- begin
- writeLn('it can not be negative, write it one more time');
- i:=0;
- end
- else if H>=0 then i:=1;
- until i=1;
- end;
- writeLn('write distance between starting point and wall');
- begin
- repeat
- Readln(L);
- if L<=0 then
- begin
- writeLn('it can not be negative, write it one more time');
- i:=0;
- end
- else if L>0 then i:=1 ;
- until i=1;
- end;
- writeLn('write inclination of the bottom, between 0 and 90 degrees');
- begin
- repeat
- Readln(B);
- if (B<0) or (B>90) then
- begin
- writeLn('it must be between 0 and 90 degrees, write it one more time');
- i:=0;
- end
- else if (B>=0) and (B<90) then i:=1 ;
- until i=1;
- end;
- writeLn('write starting, initial velocity');
- begin
- repeat
- Readln(V);
- if (V<0) then
- begin
- writeLn('do not write negative value');
- i:=0;
- end
- else if (V>0) then i:=1 ;
- until i=1;
- end;
- writeLn('write inclination of the throw, between 0 ang 90 degrees');
- begin
- repeat
- Readln(A);
- if (A<0) or (A>90) then
- begin
- writeLn('it can not be negative, write it one more time');
- i:=0;
- end
- else if (A>=0) and (A<90) then i:=1 ;
- until i=1;
- end;
- writeLn('increment time');
- begin
- repeat
- Readln(T);
- if (T<0) then
- begin
- writeLn('it can not be negative, write it one more time');
- i:=0;
- end
- else if (T>=0) then i:=1 ;
- until i=1;
- end;
- i:=0;
- y:=H;
- x:=0;
- Writeln(f, 'x',';', 'y');
- Str(x:0:2,abc);
- Str(y:0:2,cba);
- Writeln(f, abc,';', cba);
- repeat
- i:=i+0.1;
- vx:=V*(cos(A));
- vy:=V*sin(A)-(g*i);
- x:=(V*i*cos(A));
- y:=H+(V*i*sin(A)-((g/2)*(i*i)));
- u:=x*sin(B);
- V:=V*0.98;
- writeLn('');
- writeLn(i:0:2,' time of experiment');
- writeLn(V:0:2,' velocity in time');
- writeLn(vx:0:2,' velocity vector vx');
- writeLn(vy:0:2,' velocity vector vy');
- writeLn(x:0:2, ' coordinate x');
- writeLn(y:0:2, ' coordinate y');
- writeLn(u:0:2, ' coordinate u');
- Str(x:0:2,abc);
- Str(y:0:2,cba);
- Writeln(f, abc,';', cba);
- until (i>=T) or (y<=u) or (x>=L);
- close(f);
- if (i>=T) then
- writeLn('end of time');
- if y<=u then
- writeLn('bottom was reached');
- if x>=L then
- writeLn('wall is reached');
- readln(j);
- close(f);
- ;
- if ErrorMsg<>'' then begin
- ShowException(Exception.Create(ErrorMsg));
- Terminate;
- Exit;
- end;
- // parse parameters
- if HasOption('h', 'help') then begin
- WriteHelp;
- Terminate;
- Exit;
- end;
- { add your program here }
- // stop program loop
- Terminate;
- end;
- constructor TMyApplication.Create(TheOwner: TComponent);
- begin
- inherited Create(TheOwner);
- StopOnException:=True;
- end;
- destructor TMyApplication.Destroy;
- begin
- inherited Destroy;
- end;
- procedure TMyApplication.WriteHelp;
- begin
- { add your help code here }
- writeln('Usage: ', ExeName, ' -h');
- end;
- var
- Application: TMyApplication;
- begin
- Application:=TMyApplication.Create(nil);
- Application.Title:='My Application';
- Application.Run;
- Application.Free;
- end.
- program Project1;
- {$mode objfpc}{$H+}
- uses
- {$IFDEF UNIX}{$IFDEF UseCThreads}
- cthreads,
- {$ENDIF}{$ENDIF}
- Classes, SysUtils, CustApp
- { you can add units after this };
- type
- { TMyApplication }
- TMyApplication = class(TCustomApplication)
- protected
- procedure DoRun; override;
- public
- constructor Create(TheOwner: TComponent); override;
- destructor Destroy; override;
- procedure WriteHelp; virtual;
- end;
- { TMyApplication }
- procedure TMyApplication.DoRun;
- var
- ErrorMsg: String;
- begin
- // quick check parameters
- ErrorMsg:=CheckOptions('h', 'help');
- if ErrorMsg<>'' then begin
- ShowException(Exception.Create(ErrorMsg));
- Terminate;
- Exit;
- end;
- // parse parameters
- if HasOption('h', 'help') then begin
- WriteHelp;
- Terminate;
- Exit;
- end;
- { add your program here }
- // stop program loop
- Terminate;
- end;
- constructor TMyApplication.Create(TheOwner: TComponent);
- begin
- inherited Create(TheOwner);
- StopOnException:=True;
- end;
- destructor TMyApplication.Destroy;
- begin
- inherited Destroy;
- end;
- procedure TMyApplication.WriteHelp;
- begin
- { add your help code here }
- writeln('Usage: ', ExeName, ' -h');
- end;
- var
- Application: TMyApplication;
- begin
- Application:=TMyApplication.Create(nil);
- Application.Title:='My Application';
- Application.Run;
- Application.Free;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement