What is the output of this code snippet if the user enters the numbers 1 2 3 4 -1 5
double total = 0;
boolean hasValidNumber = true;
Scanner in = new Scanner(System.in);
while (in.hasNextDouble() && hasValidNumber)
{ double input = in.nextDouble();
if (input < 0)
{
hasValidNumber = false;
} else
{
total = total + input; }
}
System.out.println(total);
a) 15.0
b) 14.0
c) 12.0
d) 10.0