Question: In Java Programming 8th Edition by Joyce Farrell chapter 9 #2 part A of the question. (MeanMedian) If I enter Array values: 7 6 5

In Java Programming 8th Edition by Joyce Farrell chapter 9 #2 part A of the question. (MeanMedian)

If I enter Array values:

7 6 5 3 2

the Mean shows 4.0

the Mean should be 4.6, not 4.0. This result came from the following statement.

L22: double mean=total/nums.length;

Both total and nums.length are integers, so it will return an integer value (4.0) to mean.

I'm supposed to use a double cast operator to do an explicit conversion, How do I do that?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!