Advertisement
Spocoman

04. Sum of Chars

Oct 17th, 2024
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.40 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int n = Integer.parseInt(scanner.nextLine()),
  7.                 sum = 0;
  8.        
  9.         for (int i = 0; i < n; i++) {
  10.             sum += scanner.nextLine().charAt(0);
  11.         }
  12.        
  13.         System.out.println("The sum equals: " + sum);
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement