/**           
 *       FormatExample: Test program to allow experimentation
 *             with the printf format string for a single double.
 */

import uk.ac.ed.ph.sciprog.*;

public class FormatExample {                 // Class name
    public static void main(String args[]) { // Start of main program
	
	//          Create Display

	Display panel = new Display("Test of printf()");
     
	//          Double Input
	Input doubleInput = new Input("Give Double",Math.PI);
	panel.addInput(doubleInput);

	Input formatInput = new Input("Format","%g\n");
	panel.addInput(formatInput);

	//        Loop getting doubles and formats

	while(true) {
	    panel.waitForButtonPress();         // Wait for GO

	    //          Read in double and Format

	    double doubleValue = doubleInput.getDouble();
	    String format = formatInput.getString();
	    
	    //         Print out result

	    panel.println("Out of double is:");
	    panel.printf(format,doubleValue);
	    panel.println();               
	}
    }
}
	   
