【Java編】 学校の宿題は俺にやらせろ 【Java編】
■ このスレッドは過去ログ倉庫に格納されています
0571最後
NGNGpublic class Ex523 {
public static void main(String args[]){
if(args.length==1){
try{
System.out.println("amount;"+args[0]);
int totalamount=Integer.parseInt(args[0]);
int[] noso=new int[5];
int[] money={10000,1000,100,10,1};
for(int i=0;i<noso.length;i++){
while((totalamount - (money[i]))>=0){
noso[i]++;
totalamount=totalamount-money[i];
}
}
for(int i=0;i<money.length;i++){
System.out.println(money[i]+"円:"+noso[i]);
}
}
catch(NumberFormatException e){
System.out.println("引数には数字を入力");
}
}
else{
System.out.println("1つの引数に数字を入力");
}
}
}
■ このスレッドは過去ログ倉庫に格納されています