37 lines
716 B
Java
37 lines
716 B
Java
import java.util.Scanner;
|
|
import java.io.File;
|
|
|
|
void main() throws Exception {
|
|
int summe = 0;
|
|
int anzahl = 0;
|
|
int maximum = Integer.MIN_VALUE;
|
|
|
|
Scanner sc = new Scanner(new File("messwerte.txt"), "UTF-8");
|
|
|
|
while (sc.hasNextLine()) {
|
|
String zeile = sc.nextLine();
|
|
if (zeile.isBlank()) {
|
|
continue;
|
|
}
|
|
|
|
int eingabe = Integer.parseInt(zeile);
|
|
|
|
summe = summe + eingabe;
|
|
anzahl = anzahl + 1;
|
|
|
|
if (eingabe > maximum) {
|
|
maximum = eingabe;
|
|
}
|
|
}
|
|
|
|
sc.close();
|
|
|
|
if (anzahl >= 1) {
|
|
double durchschnitt = (double) summe / anzahl;
|
|
IO.println("Anzahl: " + anzahl);
|
|
IO.println("Durchschnitt: " + durchschnitt);
|
|
IO.println("Maximum: " + maximum);
|
|
} else {
|
|
IO.println("Keine Daten eingegeben: ");
|
|
}
|
|
} |