有人可以告訴我爲什麼我的程序沒有要求性別時,我運行它,雖然它要求的一切?程序並不要求性別,雖然它要求所有其他
import java.util.*;
public class registration {
public static void main (String[] args) {
Scanner in=new Scanner(System.in);
System.out.println("Enter first name");
String firstName=in.nextLine();
System.out.println ("Enter surname");
String surname=in.nextLine();
System.out.println ("Enter address");
String address=in.nextLine();
System.out.println ("Enter age");
int age=in.nextInt();
System.out.println ("Enter gender");
String gender=in.nextLine();
System.out.println ("Enter telephone contact");
String teleContact=in.nextLine();
System.out.println ("Enter P for Platinum, G for Gold or S for Silver membership type");
String memberType=in.nextLine();
int birth;
birth=2014-age;
String surname2;
surname2 = surname.toUpperCase();
String memberId;
memberId=memberType + surname2 + birth;
System.out.printf ("MEMBER ID : " + memberId + " ");
System.out.printf ("FIRSTNAME : " + surname + " ");
System.out.printf ("SURNAME : " + firstName + " ");
System.out.printf ("AGE : " + age + " ");
System.out.printf ("GENDER : " + gender + " ");
System.out.printf ("TELEPHONE : " + teleContact + " ");
System.out.printf ("MEMBERSHIP TYPE : " + memberType + " ");
System.out.printf ("ADDRESS : " + address + " ");
}
}
您是否提供有效年齡? – Leo