Advertisement
Guest User

Untitled

a guest
Dec 7th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4.  
  5. public class Main {
  6. public static void main(String[] args) throws IOException {
  7. BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
  8. int x = 0;
  9. int i = 0;
  10. while(i != 40){
  11. try {
  12. int a = Integer.parseInt(read.readLine());
  13. x += a;
  14. i++;
  15. }
  16. catch (NumberFormatException exp){
  17. System.out.println("Должно быть введено число");
  18. }
  19. }
  20. System.out.println(x);
  21. read.close();
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement