Assignment #46 and AgeMessgaes3
Code
/// Name: Jason Kim
/// Period: 7
/// Program Name: AgeMessages3
/// File Name: AgeMessages3.java
/// Date Finished:10/6/15
import java.util.Scanner;
public class AgeMessages3
{
public static void main (String [] args)
{
int age;
String name;
boolean condition1, condition2;
Scanner keyboard = new Scanner(System.in);
System.out.print("Your name: ");
name = keyboard.next();
System.out.print("Your age: ");
age = keyboard.nextInt();
condition1 = ( age <= 17 && age >= 16);
condition2 = ( age <= 24 && age >= 18);
System.out.println();
if ( age < 16 )
{
System.out.println( "You can't drive, " + name + ".");
}
if ( condition1 )
{
System.out.println( "You can drive but not vote, " + name + ".");
}
if ( condition2 )
{
System.out.println( "You can vote but not rent a car, " + name + ".");
}
if ( age >= 25 )
{
System.out.println("You can do pretty much anything, " + name + ".");
}
}
}
Picture of the output