java - How to use Arrays and Returning values -


so, im creating program takes user input, stores in array, , uses array various calculations returns. ive been working on while , cannot work. i'm newbie @ please help!

import java.util.scanner;  public class array {     public static int getvalues(int[] array)     {          scanner keyboard = new scanner(system.in);          system.out.println("enter series of " +             array.length + " numbers.");          (int index = 0; index < array.length; index++)         {             system.out.print("enter number " +                 (index + 1) + ": ");             array[index] = keyboard.nextint();         }     }      public static int gettotal(int[] array) {         double total = 0;         (int index = 0; index < array.length; index++)             total = total + array[index];         return total;     }      {         public static int getaverage(int[] array)         (int index = 0; index < array.length; index++)             average = (total + array[index])/4;         return average;     }      {         public static int gethighest(int[] array)         int highest = array[0];         (int index = 0; index < array.length; index++)             highest = index[4];         return highest;     }      {         public static int getlowest(int[] array)         int lowest = array[0];         (int index = 0; index < array.length; index++)             lowest = index[0];         return lowest;     } } } 

you don't have total variable in main. needs hold correct value vefore call println. suggest rid of line after println , write on line before "int total = gettotal(numbers);" without quotes ofc. gettotal method returns int store it. didn't check logic rest thought.


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -