Advertisement
Guest User

Untitled

a guest
Jun 1st, 2011
52
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // #############################################
  2. // # Patrick Freed's Amazing Averaging Machine #
  3. // # PFAAM #
  4. // #############################################
  5. import java.util.Scanner;
  6. public class MultiArrayMain {
  7. public static void main(String args[]){
  8. Scanner input = new Scanner(System.in);
  9. System.out.println("How many numbers do you want to average?");
  10. int amount = input.nextInt();
  11. double numbers[]= new double[amount];
  12. System.out.println("Enter the numbers you want to average");
  13. for(int counter = 0; counter<numbers.length;counter++){
  14. numbers[counter]=input.nextInt();}
  15. System.out.println(average(numbers));
  16. main(null);
  17. }//Main
  18. public static double average(double...stuff){
  19. double total = 0;
  20. for(double x:stuff){
  21. total+=x;}
  22. double answer = total/stuff.length;
  23. return answer;
  24. }//Average
  25. }//class
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement