I need help on age calculation java programme
Hello everyone,
I'm a new member in this sites . I study in college and this is my first time in
studing Object Oriented Programming (Java) . I really need help to find the java code of this programme as soon as possible.
The question is:
*By using calnder class Write a program in java to calculate the age in days for the given date of birth.
If any one has an idea about it tell me please and thank you all.
Re: I need help on age calculation java programme
What you can do is to first make use of the system.Calendar class. After that what you can do is to take the details from the user given in the e.g. below
using System.calendar;
class calendar
{
public double a;
Calendar c = Calendar.getInstance();
system.out.println(" enter your date of birth);
System.out.println("YEAR : " + c.get(Calendar.YEAR));
System.out.println("MONTH : " + c.get(Calendar.MONTH));
System.out.println("DAY_OF_MONTH : " + c.get(Calendar.DAY_OF_MONTH));
}
what you can do is to create the select case and create the different birth years as the options so if any of the matching value matches the select case e.g. case 1:2010
{
System.out.println("Your age is: DAYS=MONTH*30" +a);
}
. If the user enters the option say 2010 then the day will be calculated on the basis of the DAYS=MONTH*30.
If the user takes the value of say 2009 then you must put the loop as DAYS=MONTH*30+365;
So just try with this solution hope it may work for you.