Created
February 22, 2015 01:05
-
-
Save FredrikAugust/1e6c6d2ebbe242561bd5 to your computer and use it in GitHub Desktop.
Java Console Practise
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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