Advertisement
iLLcheff

VowelToLengthRatio

Oct 11th, 2022
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.24 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int lines = Integer.parseInt(scanner.nextLine());
  7.         String input = "";
  8.         String least = "";
  9.         String secondLeast = "";
  10.         int vowelCounter = 0;
  11.         int lowestVowel = Integer.MAX_VALUE;
  12.         for (int i = 0; i < lines; i++) {
  13.             input = scanner.nextLine();
  14.             for (int j = 0; j < input.length(); j++) {
  15.                 if (input.charAt(j) == 'a' || input.charAt(j) == 'o' || input.charAt(j) == 'u' || input.charAt(j) == 'e' || input.charAt(j) == 'i') {
  16.                     vowelCounter++;
  17.                 }
  18.             }
  19.             if (lowestVowel > vowelCounter) {
  20.                 lowestVowel = vowelCounter;
  21.                 least = input;
  22.                 secondLeast = least;
  23.             }
  24.             if (vowelCounter == lowestVowel && input.length() > least.length()) {
  25.                 secondLeast = input;
  26.             }
  27.             if(least.length() < secondLeast.length()){
  28.                 least = secondLeast;
  29.             }
  30.         }
  31.  
  32.         System.out.println(secondLeast + " " + lowestVowel + "/" + secondLeast.length());
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement