import java.util.*;

public class WhileExample {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int sum = 0;
    int userInput = 0;

    while(userInput != -1) {
      sum += userInput;
      System.out.print("Enter a number (type -1 to quit): ");
      userInput = scan.nextInt();
    }

    System.out.println("The total is " + sum);
    
  }
}
