Advertisement
Guest User

Untitled

a guest
May 17th, 2021
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.46 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.         String vowels = "aeiouAEIOU";
  15.  
  16.         for (int i = 0; i < n; i++) {
  17.             input[i] = scanner.nextLine();
  18.         }
  19.  
  20.         for (int i = 0; i < n; i++) {
  21.             char[] encrypt = input[i].toCharArray();
  22.             int sumVowel = 0;
  23.             int sumConsonant = 0;
  24.  
  25.             for (int j = 0; j < encrypt.length; j++) {
  26.                 String currentChar = String.valueOf(encrypt[j]);
  27.                 if (vowels.contains(currentChar)) {
  28.                     sumVowel = sumVowel + (encrypt[j] * (input[i].length()));
  29.                 } else {
  30.                     sumConsonant = sumConsonant + (encrypt[j] / (input[i].length()));
  31.                 }
  32.             }
  33.  
  34.             sort[i] = sumVowel + sumConsonant;
  35.  
  36.  
  37.         }
  38.  
  39.         for (int i = 0; i < n; i++) {
  40.             for (int j = i; j < n; j++) {
  41.                 int tempSort;
  42.                 if (sort[i] > sort[j]) {
  43.                     tempSort = sort[i];
  44.                     sort[i] = sort[j];
  45.                     sort[j] = tempSort;
  46.                 }
  47.  
  48.             }
  49.         }
  50.  
  51.         for (int i = 0; i < n; i++) {
  52.             System.out.println(sort[i]);
  53.         }
  54.  
  55.  
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement