Advertisement
Guest User

Untitled

a guest
May 17th, 2021
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5.  
  6. public class Main {
  7.  
  8. public static void main(String[] args) {
  9.  
  10. Scanner scanner = new Scanner(System.in);
  11. int n = Integer.parseInt(scanner.nextLine());
  12. String[] input = new String[n];
  13. int[] sort = new int[n];
  14.  
  15. for (int i = 0; i < n; i++) {
  16. input[i] = scanner.nextLine();
  17. }
  18.  
  19. for (int i = 0; i < n; i++) {
  20. char[] encrypt = input[i].toCharArray();
  21. int sumVowel = 0;
  22. int sumConsonant = 0;
  23.  
  24. for (int j = 0; j < encrypt.length; j++) {
  25.  
  26.  
  27. if (encrypt[j] == 'a' || encrypt[j] == 'e' || encrypt[j] == 'i' || encrypt[j] == 'o' || encrypt[j] == 'u'
  28. || encrypt[j] == 'A' || encrypt[j] == 'E' || encrypt[j] == 'I' || encrypt[j] == 'O' || encrypt[j] == 'U'
  29. ) {
  30. sumVowel = sumVowel + (encrypt[j] * (input[i].length()));
  31. } else {
  32. sumConsonant = sumConsonant + (encrypt[j] / (input[i].length()));
  33. }
  34. }
  35.  
  36. sort[i] = sumVowel + sumConsonant;
  37.  
  38.  
  39. }
  40.  
  41. for (int i = 0; i < n; i++) {
  42. for (int j = i; j < n; j++) {
  43. int tempSort;
  44. if (sort[i] > sort[j]) {
  45. tempSort = sort[i];
  46. sort[i] = sort[j];
  47. sort[j] = tempSort;
  48. }
  49.  
  50. }
  51. }
  52.  
  53. for (int i = 0; i < n; i++) {
  54. System.out.println(sort[i]);
  55. }
  56.  
  57.  
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement