Didart

Sum Of Chars

Sep 24th, 2021
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.46 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 n =Integer.parseInt(scanner.nextLine());    
  8.  
  9.         int sum = 0;
  10.         for (int count = 1; count <= n; count++) {
  11.            
  12.             char symbol = scanner.nextLine().charAt(0);
  13.             sum += (int)symbol;
  14.         }
  15.         System.out.println("The sum equals: " + sum);
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment