Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.math.*;
- public class Lesson_34_Activity_Two {
- static Scanner scanner = new Scanner(System.in);
- public static double average(int a[]) {
- double before = 0;
- double avg = 0 ;
- for(int i =0; i <a.length;i++) {
- before = before + a[i];
- }
- avg = (1.0)*(before / a.length);
- return avg;
- }
- public static void main(String[] args) {
- int a[] = {1,2,3};
- double x = average(a);
- System.out.println(x);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement