Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.73 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner zjadaczNapisow = new Scanner(System.in);
  6.         String a;
  7.         double x = 0.0;
  8.         int i = 0;
  9.  
  10.         while (true) {
  11.  
  12.             System.out.println("Wybierz liczbe:");
  13.             a = zjadaczNapisow.nextLine();
  14.             if (a.equals("")) {
  15.                 System.out.println("Srednia to: " + x / i);
  16.                 break;
  17.             } else if (Double.valueOf(a) == 0) {
  18.                 System.out.println("Srednia to: " + x / i);
  19.                 break;
  20.             } else if (Double.valueOf(a) != 0) {
  21.                 x = (x + Double.valueOf(a));
  22.             }
  23.  
  24.             i++;
  25.  
  26.         }
  27.  
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement