Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Fundamentals Study Guide

Authors: Dr. Sergio Pisano

1st Edition

B09K1WW84J, 979-8985115307

More Books

Students also viewed these Databases questions

Question

What is the primary opportunity for new firms in a mature industry?

Answered: 1 week ago