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;

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:');
readln( speed );
writeln('Now please input the angle at which the ball travelled at:');
readln( angle );
InitVel := speed * cos(speed);
writeln('This means the inital velocity is', InitVel,'.');
writeln('Please input gravity (The standard measurement of gravity is 9.81):');
readln ( Grav );
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, '!');


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?

8 Years
Discussion Span
Last Post by codeforfun

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...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.