import javax.swing.JOptionPane;
import java.util.Scanner;
public class ShippingCost
{
public static void main(String[] args)
{
Scanner input= new Scanner(System.in);
JOptionPane.showInputDialog("Please enter the length of your package: ");
double length=input.nextDouble();
JOptionPane.showInputDialog("Please enter the width of your package: ");
double width=input.nextDouble();
JOptionPane.showInputDialog("Please enter the height of your package: ");
double height=input.nextDouble();
double dimensions= length * width * height;
System.out.println("The total dimensions of your package is: " dimensions);
double charge=0;
double surcharge;
double additionalCharge;
double totalCost;
代碼編譯得很好,但是將它作為應用程式運行以測驗輸入是我遇到問題的地方。出現第一個輸入框,然后按回車后不會做任何其他事情。我是 Java 的新手,只停留在這一點上...
uj5u.com熱心網友回復:
您應該使用的回傳值JOptionPane.showInputDialog來獲取用戶的輸入,例如
double length = Double.valueOf(JOptionPane.showInputDialog("Please enter the length of your package: "));
等等。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/323095.html
