Assignment #34
Code
///Name: Cody Swain
///Period: 6
///Project Name: AgeQuestions
///File Name: AgeQuestions.java
///Date: 10/13/15
import java.util.Scanner;
public class AgeQuestions
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
String name;
int age;
System.out.println( "What is your name? " );
name = keyboard.next();
System.out.println( "Ok, " + name + ", how old are you? " );
age = keyboard.nextInt();
if ( age < 16 )
{
System.out.println( "You can't drive, " + name + "." );
}
if ( age < 18 )
{
System.out.println( "You can't vote, " + name + "." );
}
if ( age < 25 )
{
System.out.println( "You can't rent a car." );
}
if ( age > 25 )
{
System.out.println( "You can do anything that is legal." );
}
}
}
Picture of the output