Advertisement
desislava_topuzakova

Vowels_Sum

Oct 13th, 2017
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Problem9_VowelsSum {
  3. public static void main(String[] args) {
  4. {Scanner scanner=new Scanner(System.in);
  5. int suma = 0;
  6. int sume = 0;
  7. int sumi = 0;
  8. int sumo = 0;
  9. int sumu = 0;
  10. String s = scanner.nextLine();
  11. for (int i = 0; i <= s.length() - 1; i++)
  12. {
  13. if (s.charAt(i) == 'a')
  14. suma++;
  15. else if (s.charAt(i) == 'e')
  16. sume += 2;
  17. else if (s.charAt(i) == 'i')
  18. sumi += 3;
  19. else if (s.charAt(i) == 'o')
  20. sumo += 4;
  21. else if (s.charAt(i) == 'u')
  22. sumu += 5;
  23. }
  24. int ResultSum = suma + sume + sumi + sumo + sumu;
  25. System.out.println(ResultSum);
  26. }
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement