Enter your own ID number, and this number to output their own birthday, month and year.
The code is as follows:
Package com.homework.lhh;
Import Java.util.Scanner;
public class Ex03 {
String year;
String month;
String Day;
static String ID;
@SuppressWarnings ("resource") public
void inputID () {
Scanner sc = new Scanner (system.in);
System.out.println ("Please enter your ID number:");
id = sc.nextline ();
}
public void Cutid (String ID) {
year = id.substring (6, 10);//intercept years
month = id.substring (10, 12);//intercept month Day
= Id.substring (12, 14);//Intercept Day
} public
String toString () {return
"Your birthday is:" + year + "years" + month + "month" + da Y + "day." ";
}
public static void Main (string[] args) {
Ex03 Peopleid = new Ex03 ();
Peopleid.inputid ();
Peopleid.cutid (ID);
System.out.println (Peopleid.tostring ());
}
Run the results as shown in figure: