It's a code to calculate age from today's current date.
I know I'll have to use #include <ctime>
But I have no idea what I would use for the rest.
Here's my code:
package practicing;
import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;
public class FindRelativeAge {
private static Calendar calendar = Calendar.getInstance();
private static String birthDate = "";
private static String[] myArray = null;
private static int birthDay = 0;
private static int birthMonth = 0;
private static int birthYear = 0;
private static Scanner wiz = new Scanner(System.in);
public static void enterYourDumbAssBirthday() {
System.out.print("What is your birthday (e.g. 4/15/1994) -> ");
birthDate = wiz.nextLine();
myArray = birthDate.split("/");
birthDay = Integer.parseInt(myArray[1].trim());
birthMonth = Integer.parseInt(myArray[0].trim());
birthYear = Integer.parseInt(myArray[2].trim());
}
public static void findWhenYourNextDumbAssBirthdayIs() {
int currentMonth = calendar.get(Calendar.MONTH) + 1;
int currentDate = calendar.get(Calendar.DATE);
//int currentYear = calendar.get(Calendar.YEAR);
int temp = 12 - currentMonth + birthMonth;
int temp2 = currentDate -birthDay;
System.out.println("Your birthday is " + temp + " months & " + temp2 + " days away");
// System.out.println("You were born -> " + birthDate);
// System.out.println("Your next birthday is -> " + monthDifference + " months away");
// System.out.println(" -> " + dayDifference + " days away");
// System.out.println(" -> " + yearDifference + " years away");
//
}
public static void main(String[] args) {
enterYourDumbAssBirthday();
findWhenYourNextDumbAssBirthdayIs();
}
}