Sfoglia il codice sorgente

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

Александр 8 anni fa
parent
commit
6bdc6a1561
1 ha cambiato i file con 28 aggiunte e 0 eliminazioni
  1. 28 0
      src/javaapp1/Average.java

+ 28 - 0
src/javaapp1/Average.java

@@ -0,0 +1,28 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package javaapp1;
+
+/**
+ *
+ * @author Александр
+ */
+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;
+    }
+}