// CS 101 - class example // tests int and double numerical operations public class MathTest { public static void main(String[] args) { testIntMath(5, 2); testIntMath(21, 8); testDoubleMath(3.2, 4); } public static void testIntMath(int a, int b) { p("the sum of " + a + " and " + b + " is " + (a + b)); p("the product of " + a + " and " + b + " is " + (a * b)); p("the difference of " + a + " and " + b + " is " + (a - b)); p(a + " divided by " + b + " is " + (a/b)); p(a + " modulo " + b + " is " + (a%b)); } public static void testDoubleMath(double a, double b) { p("the sum of " + a + " and " + b + " is " + (a + b)); p("the product of " + a + " and " + b + " is " + (a * b)); p("the difference of " + a + " and " + b + " is " + (a - b)); p(a + " divided by " + b + " is " + (a/b)); } // shorthand for System.out.println to save typing public static void p(String s) { System.out.println(s); } }