почему не плюсует последнюю цифру, как исправить. почему выводит результат 2 раза
package com.javarush.task.pro.task04.task0403;
import java.util.Scanner;
/*
Суммирование
*/
public class Solution {
public static void main(String[] args) {
Scanner console = new Scanner(System.in);
int ab = 0 ;
int a = 0 ;
boolean Exit = false;
while (!Exit){
String str = console.nextLine();
if (console.hasNextInt()){
a = Integer.parseInt(str);
ab += a;}
else {
System.out.println(ab);
Exit = str.equals("ENTER");
}}
}
}