
public class MathFun {

	public static void main(String[] args) {
		System.out.println(Math.PI);
		
		double sqrt2 = Math.sqrt(2);
		
		System.out.println(sqrt2);
		
		//don't test a double for exact equality
		if(sqrt2*sqrt2 == 2.0) {
			System.out.println("They are equal.");
		}
		else {
			System.out.println("They are not equal?");
			System.out.println(sqrt2*sqrt2);
		}
		
		//test if the two two values are close enough
		double two = sqrt2*sqrt2;
		double close = 0.0000001;
		
		//check if it is close enough
		//Is two close to 2.0?
		if( Math.abs(two - 2.0) < close ) {
			System.out.println("They are close enough.");
		}
		else {
			System.out.println("They are not not close enough.");
		}
		
		int n = 10;
		int m = 20;
		
		System.out.println(Math.max(n, m));
		
		//formatted output - printf
		System.out.printf("Hello there.\n");
		
		//format string
		System.out.println("n equals " + n + ".");
		//%d: an integer goes here
		System.out.printf("n equals %d.\n", n);
		
		System.out.printf("n equals %d. m equals %d\n", n, m);
		
		//format specifier for double %f
		System.out.printf("The squareroot of two is %f\n", sqrt2);
		
		System.out.printf("( %d, %d)\n", n, m);
		

		
	}

}
