-
-
Save andymuncey/b7459f7e83657d141f3bafccf7b75063 to your computer and use it in GitHub Desktop.
This file contains 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
//Add code to print a message asking if the user is male, | |
//informing them to type 'true' or 'false' | |
System.out.println("Are you male? Type true or false"); | |
//Use the scanner to read in a boolean value (use the code completion to help you find the correct method), | |
//and store the boolean in a variable called isMale | |
Scanner inputScanner = new Scanner(System.in); | |
boolean isMale = inputScanner.nextBoolean(); | |
//Create an if statement to check the isMale variable, and if this value is true, | |
//print out a message informing him that he could expect to live to around 79 | |
if (isMale){ | |
System.out.println("You can expect to live to around 79"); | |
} | |
//Add another if statement, this time checking if the user is female (i.e. not male), | |
//if so, output a message informing her that she could expect to live until around 83. | |
//(Do not ask the user if they are female!) | |
if (!isMale){ | |
System.out.println("You can expect to live to around 83"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment