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 myScan = new Scanner(System.in);
- String finalWord = "";
- int countC = 0;
- int countO = 0;
- int countN = 0;
- boolean isEndOf = false;
- String input = "";
- while (!isEndOf) {
- input = myScan.nextLine();
- if (countC == 1 && countN == 1 && countO == 1) {
- System.out.print(finalWord + " ");
- countC = 0;
- countN = 0;
- countO = 0;
- finalWord = "";
- }
- // End cycle command
- if (input.equals("End")) {
- isEndOf = true;
- continue;
- }
- // Checking a-z A-Z
- if (input.matches("^[a-zA-Z]*$")) {
- if (input.charAt(0) == 'c' && countC == 0) {
- countC++;
- continue;
- } else if (input.charAt(0) == 'n' && countN == 0) {
- countN++;
- continue;
- } else if (input.charAt(0) == 'o' && countO == 0) {
- countO++;
- continue;
- }
- finalWord += input.charAt(0);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement