Assignment #24 and Age in Five Years
Code
///Name: Tim Gibson
///Period: 6
///Project Name: Age in Five Years
///File Name: AgeInFive.java
///Date Finished: 9/23/15
import java.util.Scanner;
public class AgeInFive
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
String name;
int age, a, b;
System.out.print( "Hello. What is your name? " );
name = keyboard.next();
System.out.println();
System.out.print( "Hi, " + name + "! How old are you? " );
age = keyboard.nextInt();
a = age + 5;
b = age - 5;
System.out.println();
System.out.println( "Did you know that in five years you will be " + a + " years old?" );
System.out.println( "And five years ago you were " + b + "! Imagine that!" );
}
}
Picture of the output