我必須編寫一個Java程序,告訴硬幣發出1美分到99美分的任何變化量。例如,如果金額爲86美分,則輸出將如下所示:Java程序,告訴硬幣發出1美分到99美分的任何數量變化
86美分可以作爲3個季度,1美分和1美分給出。
的25使用硬幣面值,10,5,和1。你的程序將使用以下方法(其中包括):
public static int computeCoin(int coinValue,);
// Precondition: 0 < coinValue < 100;
// Postcondition: returned value has been set equal to the maximum
//number of coins of the denomination coinValue cents that can be
//obtained from amount (a different variable) cents. amount has been
//decreased by the value of the coins, that is, decreased by
//returnedValue*coinValue.
到目前爲止,這是我,但我覺得我是錯過更多可以有人給我一隻手? 而且我也不會使用雙打代替int。
public class Assignment6{
public static void main(String [] args){
amount = (int)(Double.parseDouble(args[0])*100);
System.out.println("Five: " + computeCoin(500));
System.out.println("one: " + computeCoin(100));
System.out.println("Q : " + computeCoin(25));
System.out.println("D : " + computeCoin(10));
System.out.println("N : " + computeCoin(5));
System.out.println("P : " + computeCoin(1));
}
您需要將'amount'設爲全局變量。 – arshajii
我該怎麼做? – pasito15
就我所見,您從未使用您存儲在金額內的值。並且可以請您提供computeCoing功能或至少告訴它做了什麼? –