Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Design and implement a Java program (name it CountOccurrences) as follows: the main method reads from the user, into a single-dimensional array of size 10

Design and implement a Java program (name it CountOccurrences) as follows: the main method reads from the user, into a single-dimensional array of size 10 elements, a number of integers between 1 and 100. Then it passes the array to another method (name it Count) to determine and printout the occurrence of each value in the array and printout the results as shown below. Assume that the inputs end with 0 (sentinel value to stop the loop). Do not store the input value 0 into the array. The program should reject/ignore invalid inputs and continue to run. Design the main method such that it allows the user to re-run the program with different sets of inputs (as in previous assignments, using a sentinel loop). Document your code, and organize and space the outputs properly using escape characters as shown in the following sample outputs (notice time vs. times):

Entered integers between 1 and 100: 7 7 7 7 7 7 7 0

7 occurred 7 times

Entered integers between 1 and 100: 5 2 3 2 1 -20 5 17 220 3 2 1 0

5 occurred 2 times 2 occurred 3 times 3 occurred 2 times 1 occurred 2 times 17 occurred 1 time

Entered integers between 1 and 100: 5 22 35 22 11 -35 55 356 45 35 111 22 11 0

5 occurred 1 time 22 occurred 3 times 35 occurred 2 times 11 occurred 2 times 55 occurred 1 time 45 occurred 1 time

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

Oracle Database Administration The Essential Reference

Authors: Brian Laskey, David Kreines

1st Edition

1565925165, 978-1565925168

More Books

Students also viewed these Databases questions

Question

1. Discuss the four components of language.

Answered: 1 week ago

Question

f. What stereotypes were reinforced in the commercials?

Answered: 1 week ago