Advertisement
Guest User

EncrypSortAndPrintArray

a guest
Feb 2nd, 2020
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Arrays;
  4. import java.util.Scanner;
  5.  
  6. public class EncryptSortAndPrintArray {
  7.  
  8.     public static void main(String[] args) {
  9.         Scanner scan = new Scanner(System.in);
  10.         int n = Integer.parseInt(scan.nextLine());
  11.         // inputTextOrder пази сумата на всяко следващо име
  12.         int[] inputTextOrder = new int[n];
  13.  
  14.         int sum = 0;
  15.  
  16.         for (int i = 0; i <n ; i++) {
  17.             String name = scan.nextLine();
  18.             for (int j = 0; j <name.length() ; j++) {
  19.  
  20.                 if (name.charAt(j) == 'a' || name.charAt(j) == 'e' || name.charAt(j) == 'i' || name.charAt(j) == 'o' || name.charAt(j) == 'u' ) {
  21.                     sum += (name.charAt(j) * name.length());
  22.                 } else {
  23.                     sum += (name.charAt(j) / name.length());
  24.                 }
  25.  
  26.             }
  27.             inputTextOrder[i] = sum;
  28.             sum = 0;
  29.  
  30.  
  31.         }
  32.         Arrays.sort(inputTextOrder);
  33.         for (int total : inputTextOrder) {
  34.             System.out.println(total);
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement