如果變量直接輸入(即(5.00,20.00),它完美地計算出的變化,但如果我購買替代值和金額不計算變化?Java的替代變量
public static void makeChange()
{
double purchase;
double tendered;
Scanner scan = new Scanner (System.in);
System.out.println ("How much was the Purchase?");
purchase = scan.nextDouble();
System.out.println ("Amount Tendered");
tendered = scan.nextDouble();
System.out.println("Processing Transaction");
int ch[] = cd.makeChange(purchase, tendered); // does not calculate change correctly
...continued
你得到一個錯誤或只是錯誤的結果?你能告訴我們'makeChange(double,double)'方法嗎? – Keppil 2012-07-24 07:59:38
只是錯誤的結果,一切都變成了零 – 2012-07-24 08:01:08
嘗試打印'purchase'和'tendered',看看它們是否包含你認爲的值。 – Keppil 2012-07-24 08:02:08