borkins

09. Vowels Sum

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