/******************************* MAIN HEADER **********************************
 Title:            CS302 Physics Part 2
 Files:            Physics2.java
           
 Author:           Nathan C. Burnett ncb@cs.wisc.edu
 Collaborators:    none

 Due Date:         2/7/01
 Completion Date:  2/9/01

 Course:           CS 302, Spring 2001, All Sections
 TA:               

 Compiler:         Sun Microsytems SDK 1.2.1
 Platform:         Solaris/x86 2.6
**************************** 80 columns wide *********************************/
import javabook2.*;
import java.lang.Math;


public class Physics2 {
    
    // The gravitational constant of the Earth
    public static final double g = 9.8;

    public static void main(String[] args) {
	MainWindow mainWindow = new MainWindow("Physics Exercise");
	InputBox in = new InputBox(mainWindow);
	OutputBox out = new OutputBox(mainWindow);

	double v; // the initial velocity
	double t, t2; // time
	double d; // distance
	
	v = in.getDouble("Enter the initial velocity in m/s");
	d = in.getDouble("Enter the distance");

	t = (-v + Math.sqrt(Math.pow(v,2) + 4 * 0.5 * g * d))/g;

	out.printLine("The time is " + t + " seconds");

	out.show();
    }
}
