// Author: Kenneth Chan // email : kjc@liverpool.ac.uk // Date : October 2011 // Language: JAVA // Description: program that demonstrates a simple class of methods class mymath { /* Example of constant inside a class */ public final int KEN = 53 ; /* Method to return the "sum" of two numbers */ public double sum( double num1, double num2 ) { return num1 + num2 ; } /* Method to return the "multiplication" of two numbers */ public double multiplication( double num1, double num2 ) { return num1 * num2 ; } /* Method to return the max of two integers */ public int max( int num1, int num2) { System.out.println( "** inside max1(ints) **" ) ; if ( num1 > num2 ) return num1 ; else return num2 ; } /* Method to return the min of two integers */ public int min( int num1, int num2) { if ( num1 > num2 ) return num2 ; else return num1 ; } /* Method to return the max of two doubles */ public double max( double num1, double num2) { System.out.println( "** inside max2(floats) **" ) ; if ( num1 > num2 ) return num1 ; else return num2 ; } /* Method to return the min of two doubles */ public double min( double num1, double num2) { if ( num1 > num2 ) return num2 ; else return num1 ; } /* Method to return the circumference of a circle */ public double circumference( double radius ) { return 2*Math.PI*radius ; } /* Method to return the area of a circle */ public double area( double radius ) { return Math.PI*radius*radius ; } }