import java.util.Scanner;
public class Ex1
{
public static void main(String[] args)
{
Scanner scan = new Scanner (System.in);
String surname, firstname, country;
int year;
final int THISYEAR = 2008;
System.out.print("Please enter your surname: ");
surname = scan.nextLine();
System.out.print("Please enter your first name: ");
firstname = scan.nextLine();
System.out.print("Please enter the year you were born: ");
year = scan.nextInt();
System.out.print("Please enter your country of birth: ");
country = scan.nextLine();
System.out.print("Hi "+ firstname +" "+ surname +", you're "+ (THISYEAR-year) +" this year and you were born in "+ country +".");
}
}
紅色果part
點解我寫scan.next()就有得比user輸入
寫scan.nextLine()就會跳過左, 直接print out下面:funk:
[ 本帖最後由 silzai 於 2008-11-10 17:15 編輯 ] |