-1

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.

Android Dev
  • 1,496
  • 1
  • 13
  • 25

1 Answers1

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