Advertisement
Lyubohd

02. Ascii Sumator

Mar 19th, 2020
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.60 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         char firstChar = scanner.nextLine().charAt(0);
  8.         char secondChar = scanner.nextLine().charAt(0);
  9.         String input = scanner.nextLine();
  10.         int sum = 0;
  11.  
  12.         for (int i = 0; i < input.length(); i++) {
  13.             char currentChar = input.charAt(i);
  14.             if (currentChar > firstChar && currentChar < secondChar) {
  15.                 sum += currentChar;
  16.             }
  17.         }
  18.  
  19.         System.out.println(sum);
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement