/** * This program reports the smallest integer found in the array, as well as how many times that integer is found. */ class Main { //M public static void main(String[] args) {//main int target = 0; int [] data = new int[100]; for(int m=0; m< data.length; m++) { //loop data[m] = getRandom(100); System.out.print(data[m] + " "); } //loop System.out.println(); System.out.println("The smallest " + smallest(data) ); target = smallest(data); System.out.println("The smallest occurs " + frequency(data,target) + " times"); } //main public static int frequency (int [] data, int target) { //freq int count = 0; for(int i=0; i < data.length; i++) { if (data[i] == target) { count = count + 1; } } return count; }//freq public static int smallest(int [] data) { //small int min = 9999; for(int i=0; i < data.length; i++) { if (data[i] < min) { min = data[i]; } } return min; }//small /** Provides a random int between 0 and max, not including max @return 0 <= num < max */ public static int getRandom(int max) { //getRandom return (int)(Math.random() * max); } //getRandom }//M