Share
Explore BrainMass

Calculating Occurrences: Java Programming

Need some assistance modifying attached code to meet/produce the following requirements/output:

Write a program that reads numbers from the keyboard into an array of type int[]. Assume that there will be 50 or fewer entries in the array. The program should allow any number of numbers to be entered, up to 50 numbers. The output is to be a two-column list. The first column is a list of the distinct array elements; the second column is the count of the number of the occurrences of each element. Sort the list on entries in the first column, largest to smallest. For example:

If the following elements are input into the array -12 3 -12 4 1 1 -12 1 -1 1 2 3 4 2 3 -12

the output would be:

Num Count
4 2
3 3
2 2
1 4
-1 1
-12 4

Note: the columns should be properly spaced, as in my attached code, and there should be 1 column of numbers under each heading. Please use descriptive comments throughout so that I can understand what the code is doing.

Thank you for your assistance.

Attachments

Solution Summary

This solution provides a modified Java program that calculates occurrences.

$2.19