Assignment #34
Code
///Name: Mahima Choudhary
///Period: 6
///Project Name: HowOld
///File Name: HowOld.java
///Date Finished: 10/16/15
import java.util.Scanner;
public class HowOld
{
public static void main( String[] args )
{
String name;
int age;
Scanner keyboard = new Scanner(System.in);
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 cannot drive");
}
if ( age < 18 )
{
System.out.println( " You cannot vote");
if ( age < 25 )
System.out.println( " You cannot rent a car.");
}
if ( age >= 25 )
{
System.out.println("You can do anything that's legal.");
}
}
}
Picture of the output