Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package DataTypesVariables;
- import java.util.Scanner;
- public class SumOfChars_04 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine()); //брой символи
- int sum = 0; //сума от аски кодове
- for (int i = 0; i < n; i++) {
- char symbol = scanner.nextLine().charAt(0);
- int asciiCode = (int) symbol;
- sum += asciiCode;
- }
- System.out.printf("The sum equals: %d", sum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement