Help me to count the total number of days, months and year from date of birth not using any extra function bt using only simple fundamentals.
Asked
Active
Viewed 69 times
-1
-
Ok, I suggest you post the code you have done so far and ask a specific question so we can give you a specific question. What are you having trouble with? – Peter Lawrey Aug 25 '15 at 16:34
-
Similar to this: http://stackoverflow.com/questions/1116123/how-do-i-calculate-someones-age-in-java – Maxwellt Aug 25 '15 at 16:36
-
Actually I am new to this Java so just want to learn how to do that – Android Dev Aug 25 '15 at 16:37
1 Answers
0
Importing classes into your java project in order to simplify the means of accomplishing your application goal is fundamental in of itself. I wrote a very simple application using the Calendar function for you to take a look at. Simply expand on the code here to finish your project. Hopefully this helps. Next time you post maybe give it a try yourself first and post your code so others can further help =).
import java.util.Calendar;
import java.util.Scanner;
public class Potentials {
public static void main(String[] args) {
Calendar rightNow = Calendar.getInstance();
int yearBorn;
int age;
int decades;
Scanner scan = new Scanner(System.in);
// gets year born
System.out.println("Enter the year you were born ####");
yearBorn = scan.nextInt();
// calculates age
age = rightNow.get(Calendar.YEAR) - yearBorn;
System.out.println("You are " + age + "\n");

Rykuno
- 458
- 3
- 14