Hi i'm pretty new to java I've been having an issue when I attempt an "if-else" statement. I get syntax errors, which I'm not sure why. Thanks for your input.
import javax.swing.JOptionPane;
public class MagicDate {
public static void main(String [] args){
int month;
int day;
int year;
String input;
String message = ("This program will find a secret date");
JOptionPane.showMessageDialog(null, message);
input = JOptionPane.showInputDialog( " Enter a month of the in numeric "
+ "form");
month= Integer.parseInt(input);
input = JOptionPane.showInputDialog( " Enter a day of the in numeric"
+ " form");
day= Integer.parseInt(input);
input = JOptionPane.showInputDialog( " Enter a two digit year");
year = Integer.parseInt(input);
if(month * day == year);
{
JOptionPane.showMessageDialog(null, "The Date is Magic!");
}
else
{
(month * day != year);
JOptionPane.showMessageDialog(null, "The Date is not Magic");
}
System.exit(0);
}
}
Aucun commentaire:
Enregistrer un commentaire