text: Project
  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.
  •).
  Here is my coding so far. I can not find the coding for finding the prices that are higher than the calculated average.
  import javax.swing.*; public class ArrayProgram { public static void main(String[] args) { String[] items = {"Apples", "Bananas", "Nectarines", "Oranges", "Plums"}; double s; double a; double[] price = new double[5]; for (int i = 0; i < items.length; i++) { price[i] = Double.parseDouble(JOptionPane.showInputDialog(("Enter Price for " + items[i]))); s = sumArray(price); a = aveArray(price); higherAve(price, a); JOptionPane.showMessageDialog(null, "The total cost of these items is: $" + s); JOptionPane.showMessageDialog(null, "The average cost of these items is: $" + a); JOptionPane.showMessageDialog(null, "The prices above average are: "); } } public static double sumArray(double[] array) { double sum = 0.00; for(int s = 0; s < array.length; s++) sum += array[s]; return sum; } //This function takes in an array of values and returns the average of all the values in the array public static double aveArray(double[] array) { //First get the sum of the values in the array double sum = sumArray(array); //Then divide the sum by the number of elements in the array to arrive at the average double a = sum / (double)array.length; return a; } //This function is used to find the prices higher than the average price public static void higherAve(double[] price, double a) { } }
  This post has been edited by Dogstopper: 26 April 2010 - 07:15 AM
  Reason for edit:: Added code tags for the newbie