emodev

Untitled

Nov 19th, 2018
903
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 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.         char first = scanner.nextLine().charAt(0);
  7.         char second = scanner.nextLine().charAt(0);
  8.         String text = scanner.nextLine();
  9.  
  10.  
  11.         int start = (int) Math.min(first,second);
  12.         int end = (int) Math.max(first,second);
  13.  
  14.  
  15.         int sum = 0;
  16.         for (int i = 0; i < text.length(); i++) {
  17.             int currentChar = (int)(text.charAt(i));
  18.             if(currentChar > start && currentChar < end){
  19.                 sum += currentChar;
  20.             }
  21.         }
  22.         System.out.println(sum);
  23.     }
  24. }
Add Comment
Please, Sign In to add comment