public class Test63 {
public static void main(String[] args) {
int[] x1 = { 2, 8, -34, 16, 4, 91, -6, 21};
int[] x2 = { -34, -6, 2, 4, 8, 16, 21, 91};
// first call to method guessWhatIDo
boolean bv1 = guessWhatIDo(x1);
// second call to method guessWhatIDo
boolean bv2 = guessWhatIDo(x2);
// display the result
System.out.println("CMSC 130 - Homework 6 - What is doing the method guessWhatIDo?\n");
System.out.println("The result of calling guessWhatIDo method on array x1 is: " + bv1);
System.out.println("The result of calling guessWhatIDo method on array x2 is: " + bv2);
}
public static boolean guessWhatIDo(int[] a) {
boolean bRet = true;
for (int i = 0; i<a.length-1; i++) {
if(a[i] > a[i+1]) {
bRet = false;
break;
}
}
return bRet;
}
}