Assignemnt #24
Code
/// Name: Connor Siri
/// Period: 7
/// Program Name: Age
/// File Name: Age.java
/// Date Finished: 9/23/2015
import java.util.Scanner;
class Age{
public static void main(String[] args) {
String name;
int age, Yage, Oage, constant;
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();
constant = 5;
Yage = age - constant;
Oage = age + constant;
System.out.println( "Did you know that in five years you will be " + Oage + " years old? " );
System.out.println("And five years ago you were " + Yage + "! Imagine that! ");
}
}
Picture of the output