//------------------------------------------------------------------------------------------
// Sam Slee - CPS 006 / Summer 2005
// ClassMeth.java
//
// This demonstrates the different syntax for class methods (also called static methods).
// Class methods and regular methods are both used in the code below.
//------------------------------------------------------------------------------------------


// Have to import the Keyboard and DecimalFormat classes
import cs1.Keyboard;
import java.text.DecimalFormat;

public class ClassMeth {
	public static void main(String args[]) {
		
		// creating a new DecimalFormat object as usual
		DecimalFormat formatter = new DecimalFormat("0.##"); 
		
		// Both the 'print' and 'readDouble' methods use their class's name.
		// They DO NOT require an object to act on because they are "class methods".
		System.out.print("Please enter a decimal value: "); 
		double value = Keyboard.readDouble(); 
		
		// The 'format' method DOES require an object to act on.
		// In this case its acting on the object reference by the 'formatter' variable.
		String result = formatter.format(value);
		
		// The 'println' method DOES NOT require an object to act on.
		System.out.println(result);
	}
}
