Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2022
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class WordorNumber2 {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int n = Integer.parseInt(scanner.nextLine());
  8. char sigh = ' ';
  9. double result = 0;
  10. String allWords = "";
  11. for (int i = 1; i <= n ; i++) {
  12. String input = scanner.nextLine();
  13. sigh = input.charAt(0);
  14. if ((sigh>= 'a' && sigh <= 'z') || (sigh>= 'A' && sigh <= 'Z')){
  15. }
  16. if (sigh >= '0' && sigh <= '9') {
  17. int number;
  18. number = Integer.parseInt(input);
  19. result = result + number;
  20. }
  21. }
  22. System.out.printf("%.0f", result);
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement