I'm trying to create a SimpleBirthDay calculator.The requirement is "program must use a Scanner class and JOptionPane class to capture input from user".But i'm having a problem on getting the messagedialogbox to show the result.I found out that using the Scanner class we gonna need to insert the data into the command prompt to show the dialogbox
Am i doing this correctly.Below is my code.
import javax.swing.JOptionPane;
import java.util.Scanner;
public class InputExample2{
public static void main(String[] args){
String name = "";
int month = 0;
int date =0;
int year =0;
int newMonth;
int newDate;
JOptionPane.showInputDialog(null, "Please enter your birth month: ");
JOptionPane.showInputDialog(null, "Please enter your birth date: ");
JOptionPane.showInputDialog(null, "Please enter your year of birth: ");
Scanner input = new Scanner(System.in);
month = input.nextInt();
newMonth = (((((18 + month)*25)-333)*8)-554)/2;
year = input.nextInt();
date = input.nextInt();
newDate = (((((date * 5)+692)*20)+ year)-32940);
JOptionPane.showMessageDialog(null,
"Your Birthday is: " + newMonth + "-"
+ newDate + "-" + year);
} //main
} //class