Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner zjadaczNapisow = new Scanner(System.in);
- String a;
- double x = 0.0;
- int i = 0;
- while (true) {
- System.out.println("Wybierz liczbe:");
- a = zjadaczNapisow.nextLine();
- if (a.equals("")) {
- System.out.println("Srednia to: " + x / i);
- break;
- } else if (Double.valueOf(a) == 0) {
- System.out.println("Srednia to: " + x / i);
- break;
- } else if (Double.valueOf(a) != 0) {
- x = (x + Double.valueOf(a));
- }
- i++;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement