A Problem Solved—Computing Deviations
Explore how to use arrays in Java to store user-input numbers, calculate their average, and determine each number's deviation from that average. This lesson helps you understand array manipulation and numeric computations essential for programming with collections of data.
We'll cover the following...
We'll cover the following...
Problem statement
We wrote some code in this chapter’s first lesson that read numbers from the user and computed their average value. We will now modify that code so that it also computes the deviation of each number from the average.
We begin by defining an array numbers that ...