package lab5; public class ArrayFirst { public static void main(String[] args) { for (int i=0; i<args.length; ++i) System.out.println(args[i]); float[] a = {0.1f, 1.2f, 2.3f, 3.4f}; System.out.println("length="+a.length); int n = a.length; print("initial array a","a",a); float[] b = new float[n]; // an array of n zeros for (int i=0; i<n; ++i) b[i] = a[i]; print("b = copy of a","b",b); float[] c = new float[n]; for (int i=0; i<n; i++) c[0] = a[3]; c[1] = a[2]; c[2] = a[1]; c[3] = a[0]; print("c = reverse of b","c",c); float[] d = new float[n]; for (int i=0; i<n; i++) d[i] = (float) Math.sin(c[i]); print("d = sine of c","c",c); float min = d[0];{ if (d[1]<min) min = d[1]; if (d[2]<min) min = d[2]; if (d[3]<min) min = d[3]; System.out.println("min = "+min);} float max = d[0];{ if (d[1]>max) max = d[1]; if (d[2]>max) max = d[2]; if (d[3]>max) max = d[3]; System.out.println("max = "+max);} float sum = d[0]+d[1]+d[2]+d[3];{ System.out.println("sum = "+sum);} } private static boolean isSorted(float[] a) { System.out.println("a sorted?"); if (a[0] <= a[1] && a[1] <= a[2] && a[2] <= a[3]){ return true; }else{ return false; } } private static void print(String heading, String aname, float[] a) { System.out.println(heading); for (int i=0; i<a.length; ++i) System.out.println(aname+ "["+i+"] = "+a[i]); } }
The isSorted portion of the program won't print.