forum

Home / DeveloperSection / Forums / Take out year from input

Take out year from input

Anonymous User 1494 20-Dec-2015
My implementation : 
public class NewClass {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.println("Input your place and date birth : ");
        String birth = in.nextLine();
    }
}
And I will input MindStick, 25 Dec 2015. The problem how to change my input from string to int, and how to take only the year. So I can use for
if (2015 - year < 20 ) {
    System.out.println ("You are teen");
}

Updated on 20-Dec-2015
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By