/*Tally Lab warmup shell for Senior research course. */ import javax.swing.JOptionPane; import java.util.Scanner; import java.io.*; public class TallyJavaShell { final static int MAXNUMBERS=500; final static int MAXRANGE=16; public static int findMax(int[] array) { int max=0; // Complete this section return max; } public static void initArray(int[] array) { for(int i=0; i array[j]) minIndex=j; } temp=array[i]; array[i]=array[minIndex]; array[minIndex]=temp; } } public static int kthDataValue(int array[], int n) { return 0; //fix this method } public static void main(String[] args) { int[] tally = new int[MAXRANGE]; FileReader infile = null; try { infile = new FileReader("tallyfile.txt"); } catch (FileNotFoundException ex) { System.out.println("File does not exist"); } Scanner scanner = new Scanner(infile); int val, max; int mode, numModes; int count=0; initArray(tally); while (scanner.hasNext() && count < MAXNUMBERS) { // Complete this section count++; } printArray(tally); mode = findMax(tally); System.out.printf("Max frequency=%d\n", mode); numModes = countModes(tally, mode); int[] modes = new int[numModes]; findModes(tally, modes, numModes, mode); printModes(modes, numModes); count=0; int[] values = new int[MAXNUMBERS]; try { infile = new FileReader("tallyfile.txt"); } catch (FileNotFoundException ex) { System.out.println("File does not exist"); } scanner = new Scanner(infile); while(scanner.hasNext() && count < MAXNUMBERS) { val = scanner.nextInt(); values[count] = 0; count++; } int numValues=count; sortArray(values, numValues); int n = Integer.parseInt(JOptionPane.showInputDialog("Which data value? ")); val = kthDataValue(values,n-1); JOptionPane.showMessageDialog(null, "data=" + val); } }