/*
 * 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 mittel;

import java.util.Scanner;
/**
 *
 * @author Kleeblattsammler
 */
public class Mittel {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        
        Scanner eingabe = new Scanner(System.in);
        
        int anzahl = 0;
        double summe = 0;
        double zahl;
        double durchschnitt;
        
        System.out.println("Gib nacheinander einzelne Zahlen ein und ich gebe dir"
                + " immer den Durchschnitt der bisher eingegebenen Zahlen an. "
                + "Um das Programm abzubrechen, gib eine negative Zahl ein.");
        
        zahl = eingabe.nextInt();
        
        while (zahl >= 0) {
            
            anzahl++;
            summe = summe + zahl;
            durchschnitt = summe / anzahl;
            
            System.out.println("Der Durchschnitt ist " + durchschnitt);
            
            zahl = eingabe.nextInt();
            
        }
        
        System.out.print("Programm erfolgreich beendet!");
    }
    
}
