Can someone please help me find what is wrong with my code below. The program is suppose to add all the input numbers except for the sentinel which is -1. What am i doing wrong?
import java.util.*;
public class InClassWork
{
static Scanner console = new Scanner(System.in);
public static void main (String[] args)
{
int total = 0;
int number;
do
{
number = console.nextInt();
total = total + number;
}
while (number != -1);
System.out.println("The sum of the numbers entered is " + total);
}
}