Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // #############################################
- // # Patrick Freed's Amazing Averaging Machine #
- // # PFAAM #
- // #############################################
- import java.util.Scanner;
- public class MultiArrayMain {
- public static void main(String args[]){
- Scanner input = new Scanner(System.in);
- System.out.println("How many numbers do you want to average?");
- int amount = input.nextInt();
- double numbers[]= new double[amount];
- System.out.println("Enter the numbers you want to average");
- for(int counter = 0; counter<numbers.length;counter++){
- numbers[counter]=input.nextInt();}
- System.out.println(average(numbers));
- main(null);
- }//Main
- public static double average(double...stuff){
- double total = 0;
- for(double x:stuff){
- total+=x;}
- double answer = total/stuff.length;
- return answer;
- }//Average
- }//class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement