Didart

Sum Of Chars

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