版权声明:转载请附上本文博客链接 https://blog.csdn.net/qq_42174271/article/details/85207494
import java.text.DecimalFormat;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
@SuppressWarnings("resource")
Scanner in = new Scanner(System.in);
while(in.hasNext()) {
double a = in.nextDouble();
Absolute(a);
}
}
public static void Absolute(double a) {
DecimalFormat df = new DecimalFormat("#.00");
if (a>=0) {
System.out.println(df.format(a));
}else {
String str="" + a;
str = str.substring(1);
double b = Double.valueOf(str);
System.out.println(df.format(b));
}
}
}