What's wrong?

package com.codegym.task.task05.task0507;
/*
Arithmetic mean
*/
import java.util.Scanner;
public class Solution {
public static void main(String[] args) throws Exception {
Scanner s = new Scanner(System.in);
double sum = 0;
double num = 0;
while (true) {
double n = s.nextDouble();
if (n == -1) break;
sum += n;
num++;
}
if (sum == 0 && num > 0) System.out.println(0.0);
if (sum > 0 && num > 0)
System.out.println(sum / num);
}
}