如何減去出生年份和當前年份以顯示年齡?Java掃描儀和int不顯示年齡
Scanner user_input = new Scanner(System.in);
String birth_year;
System.out.print("Enter your the year you were born: ");
birth_year = user_input.next();
int age, current_year = 2016;
age = current_year - birth_year;
System.out.println("Your age is "+age);
謝謝!它完美的作品。 – cookieWarrior
@Zell如果有效,請將答案標爲已批准 –