Skip to content

Instantly share code, notes, and snippets.

@FredrikAugust
Created February 22, 2015 01:05
Show Gist options
  • Save FredrikAugust/1e6c6d2ebbe242561bd5 to your computer and use it in GitHub Desktop.
Save FredrikAugust/1e6c6d2ebbe242561bd5 to your computer and use it in GitHub Desktop.
Java Console Practise
import java.io.Console;
public class JavaTest {
public static void main(String[] args) {
Console console = System.console();
String firstName;
do {
firstName = console.readLine("What is your name?\n");
if (firstName.equals("Fredrik")) {
String adjective = console.readLine("Enter an adjective:\n");
console.printf("This is %s learning Java!\nHe is very %s.\n", firstName, adjective);
System.exit(0);
} else {
console.printf("Your name is not cool enough to use this awesome program.\n");
}
} while (!firstName.equalsIgnoreCase("Fredrik"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment