This is the code that reads the month, year, and date when a user enters in one line.
Scanner input = new Scanner(System.in);
int day = 0;
int month = 0;
int year = 0;
System.out.printf("enter the month, date, and year(only last two digits of year). Please insert a space between the month, day, and year");
month = input.nextInt();
day = input.nextInt();
year = input.nextInt();
This works completely fine, now the other part is displaying a message, if month*day==year, it is a magical number. It has to be displayed in a dialog box. This code is also working fine. Here is the code:
if((day * month) == year)
{
String message = String.format("%s", "It is a magical date");//If the day * month equals the year, then it is a magic number
JOptionPane.showMessageDialog(null, message);
}
if((day * month) != year)
{
String message = String.format("%s", "It is not a magical date");//If the day * month does not equal the year, it is not a magic number
JOptionPane.showMessageDialog(null, message);
}
I want to know how to get a dialog box to take inputs of the month, date, and year?