Assignemnt #37 and How Old Are You, Specifically
Code
/// Name: Brian Phillips
/// Period: 5
/// Program name: How Old are You, Specifically
/// File Name: HowOldSpecifically.java
/// Date Finished: 10/28/2015
import java.util.Scanner;
public class HowOldSpecifically
{
public static void main( String[] args )
{
String name;
int age;
Scanner Keyboard = new Scanner(System.in);
System.out.print( "Hey, what's your name? (Sorry, I keep forgetting.) ");
name = Keyboard.next();
System.out.print( "Ok, " + name + ", how old are you?" );
age = Keyboard.nextInt();
if ( age < 16 )
{
System.out.println( "You can't drive, " + name + "." );
}
else if ( age < 18 )
{
System.out.println( "You can drive but not vote, " + name + ".");
}
else if ( age < 25 )
{
System.out.println( "You can vote but not rent a car, " + name + "." );
}
else if ( age >= 25 )
{
System.out.println( "You can do just about anything" + name + "." );
}
}
}
Picture of the output