import java.util.Scanner;

public class problem1 
{
   public static void main (String args[])
   {

   // to read easily from the keyboard
   Scanner scanIn = new Scanner(System.in);

   // print out welcome message
   System.out.println("Welcome to the no-repeat protocol concept program.");
   System.out.println("Type 'quit' to exit the program.");

   // query input
   System.out.println("\nInput to clear:");
   String input = scanIn.nextLine();

   // as long as the input is different from "quit"
   while(! input.equals("quit")) 
   {
      // if the input isn't empty
      if (input.length() > 0)
      {
         // the first character will always be printed
         // this is why we tested input.length( ) > 0
         System.out.print(input.charAt(0));
   
         // scan through each character of the string until the end
            for (int i = 1; i < input.length(); i++) 
            {
               /*
                * compare the current character to the previous one
                * because we compare to previous character we start our
                * index i at 1, which is why we took the output of
                * the character 0 out of the loop, forcing us to check 
                * that the string isn't empty
                */
               if (input.charAt(i) != input.charAt(i - 1))
                  // if characters are equal then print current character
                  // otherwise do nothing
                  System.out.print(input.charAt(i));
            }
         }

         // ask for the next input before looping back and check for "quit"
         System.out.println("\n\nInput to clear:");
         input = scanIn.nextLine();
      }
   }
}
