Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String word, vowels = "aeiouyAEIOUY",
- strongWord = "";
- double strongSum = 0;
- while (!(word = scanner.nextLine()).equals("End of words")) {
- double wordSum = 0;
- for (int i = 0; i < word.length(); i++) {
- wordSum += word.charAt(i);
- }
- if (vowels.contains(String.valueOf(word.charAt(0)))) {
- wordSum *= word.length();
- } else {
- wordSum /= word.length();
- }
- if (wordSum > strongSum) {
- strongWord = word;
- strongSum = wordSum;
- }
- }
- System.out.println("The most powerful word is " + strongWord + " - " + (int) strongSum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement