package en.codegym.task.pro.task04.task0403;
import java.util.Scanner;
/*
Summation
*/
public class Solution {
public static void main(String[] args) {
//write your code here
Scanner sc = new Scanner(System.in);
int sum = 0;
boolean flag = true;
while(flag){
String str = sc.nextLine();
if(str.equals("ENTER")) {
flag=false;
}else{
int num = Integer.parseInt(str);
sum +=num;
}
}
System.out.println(sum);
}
}
first try yourself if stuck then apply this solution
Under discussion
Comments (1)
- Popular
- New
- Old
You must be signed in to leave a comment
Kevin
21 February, 02:44
Sadly, I passed this one because I just let hasNextInt() add x up... and the while exited on its own. I didn't even have to do all this...... this question needs more requirements.
0