- Near the top of the file, replace the line:
import java.util.Scanner;
with
import javax.swing.JOptionPane;
- In the body of the main method, replace the lines:
Scanner in = new Scanner(System.in);
System.out.print("How old are you?");
int age = in.nextInt();
with
String response = JOptionPane.showInputDialog(null, "How old are you?");
int age = Integer.parseInt(response);
- In the body of the main method, replace the line:
System.out.println("Next year, you'll be " + age);
with
JOptionPane.showMessageDialog(null, "Next year, you'll be " + age);
- Run the project again. Input and output should now be
accomplished through screen dialogs.