I cant get these to compile it seems to be where I'm trying to pass the Boolean value. The first one has 2 errors that don't make any sense to me
public class Date {
public int m;
public int d;
public int y;
boolean isLeapYear;
public String monthIs(){
return month;
m = Integer.parseInt(month);
}
public String dayIs(){
return day;
d = Integer.parseInt(day);
}
public Date(String year){
y = Integer.parseInt(year);
// Is y Divisible by 4
if (y % 4 == 0){
// Is y Divisible by 4 but not 100
if (y % 100 != 0)
isLeapYear = true;
// Is y Divisible by 4 and 100 and 400
else if (y % 400 == 0)
isLeapYear = true;
// It's Divisible by 4 and 100 but not 400
else
isLeapYear = false;
}
// It's not divisible by 4
else
{
isLeapYear = false;
public boolean getisLeapYear()
{
return isLeapYear;
}
}
}
}
DateJDialog class:
import javax.swing.JOptionPane;
/** This program runs the Date class to determine if
* the date entered falls within a leap year.
*/
public class DateJDialog
{
public static void main(String[] args)
{
String month;
String day;
String year;
boolean isitLeapYear;
Date date;
//Get Input
JOptionPane.showMessageDialog(null, "This program determines if the date
entered falls within a leap year.");
month = JOptionPane.showInputDialog("What month?");
day = JOptionPane.showInputDialog("What day?");
year = JOptionPane.showInputDialog("What year?");
//Create Date object
date = new Date(year);
if (date.getisLeapYear()==true);
if (isLeapYear = true)
JOptionPane.showMessageDialog(null, month + "-" + day + "-" + year
+ " does fall within a leap year.");
else
JOptionPane.showMessageDialog(null, month + "-" + day + "-" + year
+ " does not fall within a leap year.");
System.exit(0);
}
}