Solutions to final exam review questions ** Question 1 ************************************************************** //************************************************** // Histogram.java Author: Lewis and Loftus // // Solution to Programming Project 6.4 (page 316). //************************************************** import cs1.Keyboard; public class Histogram { public static void main (String[] args) { int[] ranges = new int[10]; int box; System.out.println ("Enter some numbers between 0 and 100."); System.out.print ("Signal the end by entering "); System.out.println ("a number out of that range."); int entered = Keyboard.readInt(); while (entered >= 1 && entered <= 100) { box = (entered - 1) / 10; //note integer division ranges[box] ++; entered = Keyboard.readInt(); } // print histogram for (box = 0; box < 10; box++) { System.out.print((10 * box + 1) + "-"); System.out.print((10 * box + 10) + "\t|"); for (int count = 0; count < ranges[box]; count++) System.out.print ("*"); System.out.println (); } } } ** Question 2 ************************************************************** // Return 1-d array of "row sums" of ragged, row-major, 2-d array. // Assume all rows exist. Input argument is reference to 2-d array: a public static double[] sum2dArray(double[][] a) { double[] sums = new double[a.length]; // 1-d array to store row sums for (int r=0; r