I'm killing two birds with one stone and revising my Physics by writing a Pascal program:

``````program ProjMotion(Input, Output);
var speed, angle, InitVel, Grav, Time: real;

begin;
writeln('Hello. This is a program to calculate the time a ball takes to hit the ground. Air resistance is negligble.');
writeln('Please input the speed at which the ball is struck:');
writeln('Now please input the angle at which the ball travelled at:');
InitVel := speed * cos(speed);
writeln('This means the inital velocity is', InitVel,'.');
writeln('Please input gravity (The standard measurement of gravity is 9.81):');
writeln('The equation of time in this instance is Time = Velocity - Initial Velocity / Acceleration.');
writeln('In other words Time is equal to', speed,' - ', InitVel,' /', Grav, '.');
Time := speed - InitVel / Grav;
writeln('Therfore time is equal to', Time, '!');

end.``````

The idea of the code is to find the time taken for a ball to hit the ground. My problem is when an equation is solved it is outputted as standard form (I.E -2.9E+001) and I can't figure out how to solve this problem.

Any ideas?

All 2 Replies

Repeat after me

repeat
until (sunk_in = true);

..

InitVel := speed * cos(speed);<---- i think

you have to change it for:

InitVel :=speed * cos(angle);

you can change how the numbers sho by adding example writeln(a:8:2);
lets say you have a:= 100.05
normally it would show 100.050000000000 or something like that
with writeln(a:8:2); it shows 100.05
with writeln(a:8:4); it shows 100.0500

and you should look for a way to separate the minutes and the seconds in 2 variables... like MM and SS
if you get everything in seconds then just do
IF SS> 60 Then MM:=SS Div 60 ...

i hope you get the idea...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.