Assignment # 24 and Age in Five Years
Code
/// Name: Tommy Oyuntseren
/// Period: 7
/// Program Name: AgeInFiveYears
/// File Name: AgeInFiveYears.java
/// Date Finished: 10/1/15
import java.util.Scanner;
public class AgeInFiveYears
{
public static void main (String[] args)
{
Scanner keyboard = new Scanner(System.in);
String name;
int age;
System.out.println();
System.out.print("What's your name?");
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 less!");
else
{
System.out.print("So, " + name + ", Did you know that you will be " + (age + 5)+ " in five years? You were " + (age - 5) + " five years ago.");
}
}
}
Picture of the output