Instructions

Write a program that will prompt the user for a list of 5 prices. Once the user has entered all values, your program should compute and display the following:

  • The sum of all the prices
  • The average of the prices
  • All prices that are higher than the calculated average

To better solve this problem, break your code out into the following methods:

  • sumArray – this method should receive an array and return the sum of all elements in the array. NOTE: this method produces no output.
  • aveArray – this method should receive an array and return the average of all elements in the array. NOTE: this method produces no output.
  • highPrices – this method should receive an array and an average. It should then print out all elements in the array whose values are greater than the average.

When you are finished writing these methods, create a main method that will prompt the user for the 5 prices and then call the appropriate methods.

Be sure your program demonstrates good programming style (appropriate comments, identifier names, indenting, etc).

Although your output is not required to look this way, it might look something like:

Please enter a value: 1.23
Please enter a value: 2.34
Please enter a value: 3.45
Please enter a value: 4.56
Please enter a value: 5.00
The sum of these values is $16.58
The average of these values is: $3.32
The values higher than the average are:
$3.45
$4.56
$5.67
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.