// a simple while-loop example. // keeps insulting the user until the user indicates he/she has had enough // Specifically, the loop ONLY terminates when the user types either the // uppercase 'Y' or the lowercase 'y'. import java.util.Scanner; class Insult1 { public static void main(String[] args) { Scanner s = new Scanner(System.in); String buf; char response = 'n'; // initialize for first condition // check through loop while (response != 'y' && response != 'Y') // control condition { System.out.println("Hey you! You at the keyboard! You're a jerk!!!"); System.out.print("Have you had enough (y/n)? "); buf = s.next(); // get response as a string response = buf.charAt(0); // response is the first letter } System.out.println("Have a nice day."); } }