Use the following command to generate a window input dialog
String myString=JOptionPane.showInputDialog("Enter a number: ");
use the following command to convert a string to a number
int myNumber = Integer.parseInt(myString);
and finally use the following command to print the input number to the console
System.out.println("The number is "+ myNumber);
Don't forget the following import command
import javax.swing.JOptionPane;
so that Java can recognize JOptionPane library.
電子二甲9326145陳鵬壬
回覆刪除終於好了~~!!
電子二甲9326145陳鵬壬
回覆刪除更改過的,應該ok了吧!!
9224205 江昇祐 Java Homework4
回覆刪除電子三丙 高志遠 9226307
回覆刪除