Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package TextPlocessing.MoreExercises;
- import java.util.Scanner;
- public class O2AsciiSumator {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- char a = scanner.nextLine().charAt(0);
- char b = scanner.nextLine().charAt(0);
- String text = scanner.nextLine();
- int start = Math.min(a, b);
- int end = Math.max(a, b);
- int sum = 0;
- for (int i = 0; i < text.length(); i++) {
- int charText = text.charAt(i);
- if (charText > start && charText < end) {
- sum += charText;
- }
- }
- System.out.println(sum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment