Advertisement
yovkovbpfps

For Loop Vowels Sum

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