// Class Exercise: October 22, 2009 // What will be the output of the following program? import java.util.*; public class October22 { //************ HELPER METHOD *****************// // returns true if n1 <= n2 <= n3 and false otherwise public static boolean ordered(int n1, int n2, int n3) { System.out.println("n1 = " + n1 + " n2 = " + n2 + " n3 = " + n3); if ((n1 <= n2) && (n2 <= n3)) return true; else return false; } //************ MAIN PROGRAM BEGINS HERE *****************// public static void main(String args[]) { int n1 = 32; int n2 = 4; int n3 = 21; int c1 = 686; int c2 = 936; int c3 = 988; if (ordered(n1,n2,n3)) System.out.println("n1, n2, n3 are ordered"); if (ordered(n2,n3,n1)) System.out.println("n2, n3, n1 are ordered"); if (ordered(c1,c2,c3)) System.out.println("c1, c2, c3 are ordered"); if (ordered(c2,c3,c1)) System.out.println("c2, c3, c1 are ordered"); if (ordered(n1+c1,n2+c2,n3+c3)) System.out.println("ORDERED"); } }