Assignment 37: How Old Are You, Specifiacally?
Code
/// Name: Ryan McAteer
/// Period: 5
/// Program Name: How Old Are You, Specifically?
/// File Name: Assignment37.java
/// Date Finished: 10/8/15
import java.util.Scanner;
class Assignment37
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
String name;
int age;
System.out.print( "Hello, what is your name?" );
name = keyboard.next();
System.out.print( "Hello, " + name + ", how old are you?" );
age = keyboard.nextInt();
if ( age < 16 )
{
System.out.println( "You can not drive" );
}
else if ( 16 <= age )
{
System.out.println( "You can drive, but not vote" );
}
else if ( 18 <= age )
{
System.out.println( "You can vote but not rent a car" );
}
else if ( 25 <= age )
{
System.out.println( "You can do pretty much anything" );
}
}
}
Picture of the output