Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Letters {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String input = scanner.nextLine();
- String word = "";
- int count = 0;
- String letter = "";
- while (!input.equals("End")) {
- char valid = input.charAt(0);
- if ((valid >= 'a' && valid <= 'z') || (valid >= 'A' && valid <= 'Z')) {
- if (input.equals("o") || input.equals("c") || input.equals("n")) {
- if (input.equals(letter) && count > 0) {
- word += input;
- } else {
- count++;
- letter = input;
- word += "";
- }
- } else {
- word += input;
- }
- if (count == 3) {
- System.out.print(word + " ");
- count=0;
- letter="";
- word="";
- }}
- input = scanner.nextLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement