Advertisement
Guest User

asdasd

a guest
Nov 23rd, 2014
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.21 KB | None | 0 0
  1. package hue241114;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Statistik {
  6.  
  7.     public static void main(String[] args) {
  8.         // TODO Auto-generated method stub
  9.  
  10.         Scanner eingabe = new Scanner(System.in);
  11.        
  12.    
  13.         System.out.println("In diesme Programm können Sie beliebig viele Zahlen einlesen, deren Min, Max und Mittelwert ausgeben.");
  14.         System.out.println("Bitte geben Sie hier beliebig viele Zahlen ein. Wenn Sie fertig sind eine 0 (!!!)");
  15.         int z = -1;
  16.          
  17.         int summe = 0;
  18.         int anzahl = 0;
  19.         int min = Integer.MAX_VALUE;
  20.         int max = 0;
  21.  
  22.         while (z != 0) {
  23.  
  24.                 System.out.println("Bitte gebe noch eine Zahl ein");
  25.                 z = eingabe.nextInt();
  26.  
  27.                 if (z != 0) {
  28.                         if (z < min) {
  29.                                 min = z;
  30.                         }
  31.                         if (z > max) {
  32.                                 max = z;
  33.                         }
  34.                         summe += z;
  35.  
  36.                         anzahl++;
  37.                 }
  38.  
  39.         }
  40.  
  41.         System.out.println("Min: " + min + " Max: " + max + " Durchschnitt: "
  42.                         + (summe / anzahl));
  43.         eingabe.close();
  44.     }
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement