Assignemnt #24 and Age in Five Years
Code
///Name: Luke Shin
///Period: 7
///Project Name: Age in Five Years
///File Name: AgeInFiveYears.java
///Date: 9/25/2015
import java.util.Scanner;
import java.util.InputMismatchException;
public class AgeInFiveYears
{
public static void main (String[] args)
{
Scanner keyboard = new Scanner(System.in);
String name;
int age;
try
{
System.out.println();
System.out.print("Enter your name please ");
name = keyboard.next();
System.out.println();
System.out.print("Hi, "+name+" How old are you? ");
age = keyboard.nextInt();
System.out.println();
if (age<=5) System.out.println("You can't be 5 years old or les!!!");
else
{
System.out.println("So, "+name+", do you realize that you will be "+(age+5)+" in five years? You were "+(age-5)+" five years ago.");
}
}
catch (InputMismatchException e)
{
System.out.println( "WRONG INPUT!!!" );
}
}
}
Picture of the output