|
If the program says
int yearBorn = ask("In which year were you born?");then it is storing the answer to the question in the variable called
yearBorn
. The variable is of type "int", a
number (integer). That year can be used later by using the variable
name. For example, to compute how old someone is, subtract their year
born from the current year.
int age = 2013 - yearBorn;Then print this out:
System.out.println("You are this old: " + age);
Copyright © 2024 Andrew Oliver