import java.util.Scanner;

public class Echo {
	public static void main(String[] args){
		//make a Scanner object to get input
		Scanner scan = new Scanner(System.in);
		
		//make a String to store user input
		String s = "";
		  
		//while s does not equal "exit"...
		while(!s.equals("exit")){
			//ask user for an input
			System.out.println("Please enter something: (type \"exit\" to quit)");
			
			//store the user's input
			s = scan.nextLine();
			
			//echo the input back to the user
			System.out.println(s);
		}	
		
		//do this loop once first
		do{
			//ask user for an input
			System.out.println("Please enter something: (type \"exit\" to quit)");
			
			//store the user's input
			s = scan.nextLine();
			
			//echo the input back to the user
			System.out.println(s);
		}while(!s.equals("exit"));
		/*
		 * You can see that the while statement is at the bottom. With a do-while loop,
		 * the code inside the loop will ALWAYS RUN AT LEAST ONCE. After the first run,
		 * it will loop again if the while statement is true.
		 */
		
		
		//dispose of the "scan" object once we are done with it
		/*
		 * This is extra to what has been taught. By closing the Scanner, we are telling
		 * the system that we are done using it. The system will then do "automatic
		 * garbage collection", which frees up the memory that was used by this object.
		 * 
		 * If you do not properly dispose of objects, you will end up with a memory leak,
		 * which means your system has no memory left and it will freeze/crash.
		 */
		scan.close();
		
	}
}
