Computer Science 523
Advanced Programming
Summer 2014, The College of Saint Rose
OlderYoungerThanJava BlueJ Project
Click here to download a BlueJ project for OlderYoungerThanJava.
OlderYoungerThanJava Source Code
The Java source code for OlderYoungerThanJava is below. Click on a file name to download it.
/** * Class example demonstrating the if-else statement * * It prompts for a birth year, prints out what age that person will * turn this year, and then one of two messages, depending on whether * that person is older or younger than the Java programming language * * Jim Teresco, The College of Saint Rose, CSC 202, Fall 2012 * Updated for, The College of Saint Rose, CSC 523, Summer 2014 * * $Id: OlderYoungerThanJava.java 2366 2014-05-20 02:33:22Z terescoj $ */ import java.util.Scanner; public class OlderYoungerThanJava { public static void main(String args[]) { final int THIS_YEAR = 2014; final int JAVA_BIRTH_YEAR = 1995; Scanner kbd = new Scanner(System.in); System.out.print("What year were you born? "); int birthYear = kbd.nextInt(); System.out.println("Hey, you turn " + (THIS_YEAR - birthYear) + " this year!"); if (birthYear < JAVA_BIRTH_YEAR) { System.out.println("You are older than Java!"); } else { System.out.println("You do not know a world without Java..."); } } }