public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int sum=0; while (true) { String str = scanner.nextLine(); if(str.equals("exit")){ System.out.println(sum); break; } int x = Integer.parseInt(str); sum = sum + x; } }}