Question
(Intro to Java help?) Write a static method named evenNumbers that accepts a string of text as a parameter. Assume that the text is a
(Intro to Java help?)
Write a static method named evenNumbers that accepts a string of text as a parameter. Assume that the text is a series of integers, and process this text and report various statistics about the integers. Report the total number of numbers, the sum of the numbers, the total count of even numbers and the percent of even numbers. For example, if the string is the following:
"5 7 2 8 9 10 12 98 7 14 20 22"
Your method should produce the following output.
Total numbers = 12
Sum of numbers = 214
Total evens = 8
Percent evens = 66.66666666666667
If a non-integer element is encountered, it should be ignored & not cause the program to crash. For example: "5 7 2 8 9 10 oops 12 98 7 14 20 22" will product output identical to the original example above.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started