galinyotsev123

ProgBasics06For-Loop-P08vowelsSum

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