我只希望显示2个小数点println不起作用,或者我错了。
我尝试使用println,但不起作用
double p=1000;
double r= 0.05;
int n;
double a;
System.out.println("Year \tAmount of Money");
for( n=1; n<=10; n++){
double exp = Math.pow((1+r),n);
a = p*exp;
System.out.println(n+"\t"+a);
我希望“ a”的输出仅显示两位小数。