001    package de.hska.java.aufgaben.kontrollstrukturen;
002    
003    /**
004     * Ein Online-Algorithmus zu Berechnung des arithmetischen
005     * Mittels von Zahlen.
006     * 
007     * @author Christian Pape
008     *
009     */
010    public class ArithmetischesMittelOnline {
011    
012        /**
013         * @param args
014         */
015        public static void main(String[] args) {
016            double wert;
017            double summe = 0.0;
018            int anzahl = 0;
019            do {
020                System.out.print("Geben Sie eine Zahl ein (Abbruch mit negativer Zahl) : ");
021                wert = Eingabe.readDouble();
022                if (wert >= 0) {
023                    summe += wert;
024                    anzahl++;
025                }
026            } while ( wert > 0 );
027            
028            System.out.println("Durchschnitt ist " + (summe / anzahl));
029        }
030    
031    }