Browse Source

Создана ветвь

Александр 8 years ago
parent
commit
60cb3bb788
1 changed files with 8 additions and 13 deletions
  1. 8 13
      src/javaapp1/Average.java

+ 8 - 13
src/javaapp1/Average.java

@@ -11,18 +11,13 @@ package javaapp1;
  */
 import java.io.*;
 import java.util.Scanner;
- 
+
 class Average{
-public static void main(String args[]) throws IOException {
-    Scanner in = new Scanner(System.in);
-    int n;
-    double sum = 0.0;
-    double avg, t;
-    n = in.nextInt();
-    for(int i=0; i < n ; i++) {
-    t = in.nextDouble();
-    sum += t;
-    }
-    avg = sum / n;
-    }
+public double averageMark(double[] marks){
+double sum=0.0;
+for(int i=0;i<marks.length;i++){
+    sum+=marks[i];
+}
+return sum/marks.length;
+}
 }