Advertisement
Guest User

Untitled

a guest
May 31st, 2011
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. //Patrick Freed
  2. import java.util.Scanner;
  3.  
  4. public class MultiArrayMain {
  5. public static void main(String args[]){
  6. Scanner input = new Scanner(System.in);
  7. System.out.println("How many numbers do you want to average?");
  8. int amount = input.nextInt();
  9. int numbers[]= new int[amount];
  10. System.out.println("Enter the numbers you want to average");
  11. for(int counter = 0; counter<numbers.length;counter++){
  12. numbers[counter]=input.nextInt();}
  13. System.out.println(average(numbers[1], numbers[2], numbers[3], numbers[4], numbers[5], numbers[6]));
  14.  
  15.  
  16. }
  17.  
  18. public static int average(int...numbers){
  19. int total = 0;
  20. int array[] = new int[numbers.length];
  21. for(int x:numbers){
  22. total+=x;
  23. }
  24.  
  25. return total/numbers.length;
  26.  
  27. }
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement