Connect with one of the following accounts


Please wait while we redirect...

Views: 202   

Following program shows you how to take birth year and tells age.
In this program we get birth year from user and tells their age using - birthYear

import java.time.Year;
import java.util.Scanner;

public class Basic8 {

    public static void main(String[] args) {

        System.out.println("Please enter your date of birth:");

        Scanner in = new Scanner(;
        int birthYear = in.nextInt();

        int age = - birthYear;

        System.out.println("Your age is " + age);




Please enter your date of birth:
Your age is 28

On By

Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News