import javabook.*;

/*
 * Introduction to OOP with Java 2nd Edition, McGraw-Hill
 *	
 *  Watermelon Dropping
 *   
 *  A sample program from Section 7.5.
 *  
 * @author Dr. Caffeine
 *
 */
class Watermelon
{
    
    public static void main (String[] args)
    {
        MainWindow  mainWindow;
        OutputBox 	outputBox;
        InputBox    inputBox;  
        
        mainWindow = new MainWindow("Drop WaterMelon");
        outputBox  = new OutputBox( mainWindow );
        inputBox   = new InputBox ( mainWindow );
                
        mainWindow.setVisible( true ); 
        outputBox.setVisible( true );
        
        double    initialHeight, 
                  position, 
                  touchTime;


        initialHeight    = inputBox.getDouble("Initial Height:");
        touchTime        =  Math.sqrt(initialHeight / 16.0);
        
        outputBox.printLine("   Time t     Position at Time t ");
        outputBox.skipLine(1);
        
        for (int time = 0; time < touchTime;  time++) {
            position = -16.0 * time*time + initialHeight;
            outputBox.print("    " + time);
            outputBox.printLine("             " + position);
        }
        
        //print the last second
        outputBox.printLine("    " + touchTime + "       0.00");
    }
    
}