Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Words {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- String bestWord = "";
- int point = 0;
- String command = scan.nextLine();
- while(!command.equals("END OF GAME")){
- int currentPoints = 0;
- for(int i = 0;i < command.length();i++){
- currentPoints += (int)command.charAt(i);
- }
- if(command.length() >= 10) {currentPoints += 30; }
- if(command.endsWith("t")) { currentPoints += 20; }
- if((int)command.charAt(0) >= 65 && (int)command.charAt(0) < 91){ currentPoints += 15; }
- if(currentPoints > point){
- point = currentPoints;
- bestWord = command;
- }
- command = scan.nextLine();
- }
- System.out.println("Winner is word: " + bestWord);
- System.out.println("Points: " + point);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment