노트/Fortran 연습

Program 2.1. 발사체 문제

Jae-seong Yoo 2014. 3. 22. 23:06
PROGRAM Projectile
!---------------------------------------------------------------------------------
!	This program calculates the velocity and height of a projectile
!	given its initial height, initial velocity, and constnat
!	acceleration. Identifiers used are :
!
!	InitialHeight		: initial height of projectile (meters)
!	Height				: height at any time (meters)
!	InitialVelocity		: initial vertical velocity (m/sec)
!	Velocity				: vertical velocity at the time (m/sec)
!	Acceleration		: vertical acceleration (m/sec/sec)
!	Time					: time since launch (seconds)
!---------------------------------------------------------------------------------

	IMPLICIT NONE

	REAL :: InitialHeight, Height, InitialVelocity, Velocity, &
				Acceleration = -9.80665, &
				Time

	! Obtain values for InitialHeight, InitialVeloc, and Time
	PRINT *, "Enter the initial height (m) and velocity (m/sec):"
	READ *, InitialHeight, InitialVelocity
	PRINT *, "Enter time in seconds at which to calculate height and velocity:"
	READ *, TIME

	! Calculate the height and velocity
	Height = 0.5 * Acceleration * Time ** 2 &
				+ InitialVelocity * Time + InitialHeight
	Velocity = Acceleration * Time + InitialVelocity

	! Display Velocity and Height
	PRINT *, "At time", Time, "seconds"
	PRINT *, "the velocity velocity is", Velocity, "m/sec"
	PRINT *, "and the height is", Height, "meters"

	pause
End PROGRAM Projectile