我必须编写一个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功能或至少告诉它做了什么? –