谁帮我看一下这段代码错在哪里(java)

来源:百度知道 编辑:UC知道 时间:2024/06/17 22:56:31
public class Interest
{
public static void main( String args[] )
{
double amount;
double principal = 1000.0;
double rate = 0.05;

System.out.printf( "%s%20s\n","Year","Amount of deposit" );

for( int year = 1 ; year <= 10 ; year++)
{
amount = principal * Math.pow( 1.0 + rate,year );

System.out.printf( "%4d%,20.2f\n",year,amount );
}
}
}

没错,真的可能是你的环境变量配的不对了。
结果:
Year Amount of deposit
1 1,050.00
2 1,102.50
3 1,157.63
4 1,215.51
5 1,276.28
6 1,340.10
7 1,407.10
8 1,477.46
9 1,551.33
10 1,628.89

没错啊。.....正常编译....
你环境变量配的不对吧..

的确有......