savovaap_

Game Of Words

May 24th, 2019
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Words {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner scan = new Scanner(System.in);
  7.         String bestWord = "";
  8.         int point = 0;
  9.  
  10.         String command = scan.nextLine();
  11.         while(!command.equals("END OF GAME")){
  12.             int currentPoints = 0;
  13.             for(int i = 0;i < command.length();i++){
  14.                 currentPoints += (int)command.charAt(i);
  15.             }
  16.  
  17.             if(command.length() >= 10) {currentPoints += 30; }
  18.             if(command.endsWith("t")) { currentPoints += 20; }
  19.             if((int)command.charAt(0) >= 65 && (int)command.charAt(0) < 91){ currentPoints += 15; }
  20.  
  21.             if(currentPoints > point){
  22.                 point = currentPoints;
  23.                 bestWord = command;
  24.             }
  25.  
  26.             command = scan.nextLine();
  27.         }
  28.  
  29.         System.out.println("Winner is word: " + bestWord);
  30.         System.out.println("Points: " + point);
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment