Question: complete the code public class CountNumbersInArray { /** Main method */ public static void main(String[] args) { java.util.Scanner input = new java.util.Scanner(System.in); System.out.print(Enter the integers

complete the code

public class CountNumbersInArray { /** Main method */ public static void main(String[] args) { java.util.Scanner input = new java.util.Scanner(System.in); System.out.print("Enter the integers between 1 and 100: ");

/* counts[1] is to keep track how many times 1 occurs. * counts[2] is to keep track how many times 1 occurs. * ... * counts[100] is to keep track how many times 1 occurs. * counts[0] is not used!!!!!! * Therefore, we need an array with 101 elements */ int[] counts = new int[101]; // TODO1: Write a WHILE loop below to get integers from user. // Increase the proper counter for each input. An input 0 ends // the loop. // Please don't over think. It is simply while not-done, keep going loop. // Refer to the slides for Ch5, Loop Categories for example code.

displayCounts(counts); } //end of main

/* * Method displayCounts: * Given an array of counts, display the count only if the count > 0 * If a count is greater than 1, the plural word "times" is used in * the output. Refer to the problem description in the word document. */ public static void displayCounts(int[] counts) { // TODO2: implenment the method body. } //end of displayCounts }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!