import java.util.*;
import java.lang.*;
import java.io.*;
class Ideone
{
public static void main (String[] args) throws java.lang.Exception
{
int w, a;
double withdrawal;
double amount;
double left;
Scanner in = new Scanner(System.in);
w = in.nextInt();
amount = in.nextDouble();
withdrawal = (double)w;
left=amount-withdrawal-0.50;
if(withdrawal+0.50>amount){System.out.println("%.2f",amount);}
else if(withdrawal%5!=0){System.out.println("%.2f",amount);}
else{System.out.println("%.2f",left);}
}
}
我读了接受的答案here,但它给出了错误:
Ideone.java:21: error: no suitable method found for println(String,double)
if(withdrawal+0.50>amount){System.out.println("%.2f",amount);}
所以我想知道我的实现有什么问题,以及正确的方法是什么。感谢。
答案 0 :(得分:0)
为什么不使用
system.out.print("%.2f");
system.out.println(amount);
据我所知, println()
不能接受2个论点