Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class LettersSymbolsNumbers {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- int sumLetters = 0;
- int sumNumbers = 0;
- int sumSymbols = 0;
- int n = input.nextInt();
- input.nextLine();
- for (int i = 0; i < n; i++) {
- String currentString = input.nextLine();
- for (int j = 0; j < currentString.length(); j++) {
- char currChar = currentString.charAt(j);
- if (Character.isLetter(currChar)) {
- currChar = Character.toUpperCase(currChar);
- sumLetters += (((int) currChar - 64) * 10);
- }
- else if (Character.isDigit(currChar)) {
- sumNumbers += Character.getNumericValue(currChar) * 20;
- }
- else {
- if (!Character.isWhitespace(currChar)) {
- sumSymbols += 200;
- }
- }
- }
- }
- System.out.printf("%d\n%d\n%d", sumLetters, sumNumbers, sumSymbols);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement