Advertisement
veronikaaa86

06. Vowels Sum

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