// Program to test solutions to problem #6 on the cse142 midterm, winter 2011. // Fill in your solution to numUnique, then compile and run the program. import java.util.*; public class Test6 { public static int numUnique(int x, int y, int z) { // fill in your solution here // you can also rename the parameters above } // this is the sample solution public static int numUnique2(int x, int y, int z) { if (x == y && y == z) { return 1; } else if (x != y && x != z && y != z) { return 3; } else { return 2; } } public static void main(String[] args) { test(18, 3, 4); test(6, 6, 6); test(7, 31, 7); test(31, 7, 7); test(7, 7, 31); } public static void test(int x, int y, int z) { System.out.println("testing " + x + ", " + y + ", " + z); int num1 = 0; boolean fail = false; try { num1 = numUnique(x, y, z); } catch (RuntimeException e) { System.out.println("threw " + e); fail = true; } int num2 = numUnique2(x, y, z); System.out.println("correct = " + num2 + ", theirs = " + num1); if (!fail && num1 == num2) { System.out.println("PASS"); } else { System.out.println("FAIL"); } System.out.println(); } }