import java.util.Scanner;
import javax.swing.JOptionPane;
public class ParisProject
{
public static void main(String[]args)
{
// declare and construct variables
String date, year, day2, month2, year2;
int day, month;
boolean leapYear;
// print prompts and get input
System.out.println("\tARE YOU BORN ON A LEAPYEAR?");
date=JOptionPane.showInputDialog(null,"Please enter your birthday in this format, mm/dd/yyyy.","ARE YOU BORN ON A LEAPYEAR?", JOptionPane.PLAIN_MESSAGE );
// date = sc.nextLine();
day2=JOptionPane.showInputDialog(null,"Please enter the day you were born on in this format, dd.");
day= Integer.parseInt((day2));
month2=JOptionPane.showInputDialog(null,"Please enter the month you were born on in this format, mm.");
month= flag(formatMonth(date));
year=JOptionPane.showInputDialog(null,"Please enter the year you were born on in this format, yyyy.");
year=formatYear(date);
// calculations
Scanner sc = new Scanner(System.in);
leapYear=leapYear(date);
// output
JOptionPane.showMessageDialog(null,"It is "+leapYear+" that the year "+year+" is a leap year", "Huh?", JOptionPane.PLAIN_MESSAGE);
switch(month)
{
case 1:System.out.println("The date is: January "+day+", "+year); break;
case 2:if(day<=28){
System.out.println("The date is: February "+day+", "+year); }
break;
case 3:JOptionPane.showMessageDialog(null, "The date is: March "+day+", "+year, "Title", JOptionPane.INFORMATION_MESSAGE); break;
case 4:
System.out.println("The date is: April "+day+", "+year); break;
case 5:System.out.println("The date is: May "+day+", "+year); break;
case 6:System.out.println("The date is: June "+day+", "+year); break;
case 7:System.out.println("The date is: July "+day+", "+year); break;
case 8:System.out.println("The date is: August "+day+", "+year); break;
case 9:System.out.println("The date is: September "+day+", "+year); break;
case 10:System.out.println("The date is: October "+day+", "+year); break;
case 11:System.out.println("The date is: November "+day+", "+year); break;
case 12:System.out.println("The date is: December "+day+", "+year); break;
default: System.out.println("What planet are you living on with that kind of date? Please, try again!");}
}
public static int formatMonth(String q)
{
String month = q.substring(0,2);
int m = flag(Integer.parseInt(month));
return m;
}
public static int flag(int month)
{
if(month==1)
month=1;
if(month==2)
month=2;
if(month==3)
month=3;
if(month==4)
month=4;
if(month==5)
month=5;
if(month==6)
month=6;
if(month==7)
month=7;
if(month==8)
month=8;
if(month==9)
month=9;
if(month==10)
month=10;
if(month==11)
month=11;
if(month==12)
month=12;
return month;
}
public static String formatYear(String q)
{
String year;
year = q.substring(6,10);
return year;
}
public static boolean leapYear(String q)
{
String year=q.substring(6,10);
int leap=Integer.parseInt(year);
{
if ((leap%4)==0 && (leap%100)!=0)
return true;
if ((leap%4)==0&&(leap%100)==0&&(leap%400)==0)
return true;
else
return false;
}
}
}