Advertisement
deyanmalinov

04. Sum of Chars

Feb 13th, 2019
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.55 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.*;
  4.  
  5. public class Main {
  6.         public static void main(String[] args) {
  7.             Scanner scan = new Scanner(System.in);
  8.             int lines = Integer.parseInt(scan.nextLine());
  9.             int sum = 0;
  10.             for (int i = 0; i < lines; i++) {
  11.                 String chark = scan.nextLine();
  12.                 char znak = chark.charAt(0);
  13.                 int znakASCI = znak;
  14.                 sum +=znakASCI;
  15.  
  16.             }
  17.             System.out.println("The sum equals: " + sum);
  18.         }
  19.  
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement