Advertisement
Guest User

Untitled

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