Assignemnt #46
Code
/// Name: Daniel Nguyen
/// Period: 6
/// Program Name: Agemessage Program
/// File Name: Agemessage.java
/// Date Finished: 9/9/2015
import java.util.Scanner ;
public class Agemessage
{
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( "How old are you " + name + " ?" );
age = keyboard.nextInt();
if ( age < 16 ) {
System.out.println( "You can't drive." );
}
if ( age >= 16 && age <= 17 ) {
System.out.println( "You can drive but not vote." );
}
if ( age >= 18 && age <= 24 ) {
System.out.println( "You can vote but not rent a car." );
}
if ( age >= 25 ) {
System.out.println( "You can pretty much do anything." );
}
}
}
Picture of the output