Advertisement
YavorGrancharov

VowelsSum

Jan 27th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.81 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class VowelsSum {
  4.     public static void main(String[] args) {
  5.         Scanner console = new Scanner(System.in);
  6.         String s = console.nextLine();
  7.         int sum = 0;
  8.  
  9.         for (int i = 0; i < s.length(); i++) {
  10.             char letter = s.charAt(i);
  11.             switch (letter) {
  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
Advertisement