Assignemnt #24 and Age In Five Years
Code
/// Name: Brian Phillips
/// Period: 5
/// Program name: Age in Five Years
/// File Name: AgeFiveYears.java
/// Date Finished: 10/8/2015
import java.util.Scanner;
public class AgeFiveYears
{
public static void main( String[] args )
{
String name;
int age, ageOlder, ageYounger;
Scanner keyboard = new Scanner(System.in);
System.out.print( "Hello. What is your name? " );
name = keyboard.next();
System.out.print( "Hi, " + name + "! How old are you? " );
age = keyboard.nextInt();
ageOlder = age + 5;
ageYounger = age - 5;
System.out.println( "Did you know that in five years you will be " + ageOlder + " years old?" );
System.out.println( "And five years ago you were " + ageYounger + "! Imagine that!" );
}
}
Picture of the output