Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2020
933
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.12 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Letters {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         String input = scanner.nextLine();
  8.         String word = "";
  9.         int count = 0;
  10.         String letter = "";
  11.  
  12.  
  13.         while (!input.equals("End")) {
  14.             char valid = input.charAt(0);
  15.             if ((valid >= 'a' && valid <= 'z') || (valid >= 'A' && valid <= 'Z')) {
  16.                 if (input.equals("o") || input.equals("c") || input.equals("n")) {
  17.                     if (input.equals(letter) && count > 0) {
  18.                         word += input;
  19.                     } else {
  20.                         count++;
  21.                         letter = input;
  22.                         word += "";
  23.                     }
  24.                 } else {
  25.                     word += input;
  26.                 }
  27.                 if (count == 3) {
  28.                     System.out.print(word + " ");
  29.                     count=0;
  30.                     letter="";
  31.                     word="";
  32.                 }}
  33.                 input = scanner.nextLine();
  34.  
  35.  
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement