// Scott DeRuiter 10/8/2002 // Projectile.java // Simulation of a projectile being fired into the air. // 7/15/2011 - Greenstein: Changed TextReader to Scanner import java.util.Scanner; public class Projectile { private int seconds; private double height, velocity; public Projectile ( ) { seconds = 0; height = velocity = 0.0; } public static void main ( String [] args ) { Projectile rock = new Projectile ( ); rock.GetVelocity ( ); rock.ShowAltitude ( ); } public void GetVelocity ( ) { Scanner keyinput = new Scanner ( System.in ); System.out.print ( "\n\nEnter the initial velocity in ft/sec^2 -> " ); velocity = keyinput.nextDouble ( ); } public void ShowAltitude ( ) { if ( velocity > 0.0 ) { System.out.println ( "\n\nSeconds Height" ); while ( height >= 0.0 ) { System.out.println ( seconds + " " + height ); seconds++; height = -16.0 * seconds * seconds + velocity * seconds; } } } }