Assignemnt #24 Age In 5 Years
Code
Name: Iaroslav Titov
Period: 7
Project Name: AgeInFiveYears
File Name: AgeInFiveYears.java
Date: 9/22/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.print("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