import java.util.Scanner;
import javax.swing.JOptionPane;
public class moneyRate {
public static void main(String[] args) {
//Get Inputs
Scanner input = new Scanner(System.in);
JOptionPane.showInputDialog("How many old pounds? ");
double oldPounds = input.nextDouble();
JOptionPane.showInputDialog("How many old shillings? ");
double oldShillings = input.nextDouble();
JOptionPane.showInputDialog("How many old pennies? ");
double oldPennies = input.nextDouble();
input.close();
//New Pounds calc
double newPounds = ((oldPounds*160.80) + (oldShillings*8.04) + (oldPennies*0.67));
System.out.print("Your old pounds shillings and pennies are equal to £4"
+ "" + newPounds + ".");
}
}
在編程類,我們被要求做一個程序,它會告訴他們的老英鎊先令便士多少是當今萬鎊身價的用戶。我已經完全使用控制檯作爲程序的輸入和輸出,但現在當我嘗試使用JOptionPane
來做到這一點時,向用戶展示小型彈出框不起作用。當我運行任務時,只有第一個彈出窗口顯示,程序剛剛結束,沒有任何形式的錯誤消息。我假設這是一個簡單的語法錯誤,但我無法發現它。JOptionPane.showInputDialog只顯示了一次
如果有人察覺錯誤,請幫助我,謝謝:)
你爲什麼不從joption窗格中輸入內容 – 2014-10-02 07:52:23