beyondgrader.com Logo
DemoBrowseAboutTeamLogin

Print Number Summary

Geoffrey Challen // 2022.7.0

Let's print some fun statistics about some numbers! Write a method named processNumbers that accepts a single String as input. The String will contain, on separate lines, integer values. However, some lines may be blank, and other integers may have whitespace before or after. Here's an example:

1

  2
 4

Process the String line by line, using Integer.parseInt to convert each line to an int value. Print a report when you are done in the following format, in this case using the numbers shown above:

Count: 3
Sum: 7
Count Even: 2
Count Odd: 1
Average: 2.3

Note that you should format the average with a single decimal place. You should examine how to use the Math.round method and a bit of cleverness to accomplish this.