martinvalchev

Vowels Sum

Nov 4th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class VowelsSum {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         String word = scanner.nextLine();
  7.         int sum = 0;
  8.  
  9.         for (int i = 0; i < word.length() ; i++) {
  10.             char symbol = word.charAt(i);
  11.             switch (symbol) {
  12.                 case 'a':
  13.                     sum += 1;
  14.                     break;
  15.                 case 'e':
  16.                     sum += 2 ;
  17.                     break;
  18.                 case 'i':
  19.                     sum += 3;
  20.                     break;
  21.                 case 'o':
  22.                     sum += 4 ;
  23.                     break;
  24.                 case 'u':
  25.                     sum += 5;
  26.                     break;
  27.             }
  28.         }
  29.         System.out.println(sum);
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment