Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class TheMostPowerfullWord {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String word = scanner.nextLine();
- String mostPowerfulWord = "";
- int maxPts = 0;
- while (!word.equals("End of words")){
- int pts = 0;
- for (int i = 0; i <word.length() ; i++) {
- pts += word.charAt(i);
- }
- if(word.charAt(0) == 'a' || word.charAt(0) == 'e' || word.charAt(0) == 'i' || word.charAt(0) == 'o' || word.charAt(0) == 'u' ||
- word.charAt(0) == 'y' || word.charAt(0) == 'A' || word.charAt(0) == 'E' || word.charAt(0) == 'I' ||
- word.charAt(0) == 'O' || word.charAt(0) == 'U' || word.charAt(0) == 'Y' ){
- pts *= word.length();
- }else{
- pts /= word.length();
- }
- if(pts > maxPts){
- maxPts = pts;
- mostPowerfulWord = word;
- }
- word = scanner.nextLine();
- }
- System.out.printf("The most powerful word is %s - %d",mostPowerfulWord,maxPts);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement