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