public class CompoundInterest 
{
public static void mian(String[] args)
{
final double STARTRATE = 10;
final int NRATES = 6;
final int NYEARS = 10;

//set interest rates to 10.....15
double[] interestRate = new double[NRATES];
for(int j=0; j<interestRate.length; j++)
interestRate[j] = (STARTRATE + j)/100.0;

double[][] balances = new double[NRATES][NYEARS];

//set initial balances to 10000
for(int j=0; j< balances[0].length; j++)
balances[0][j] = 10000;

// copute interest for future years
for(int i=1;i<balances.length; i++)
{
for(int j=0; j<balances[i].length; j++)
{
// get last year's balances from previous row
double oldBalance = balances[i-1][j];

// compute interest
    double interest = oldBalance * interestRate[j];
    
   // compute this year's balances
    balances[i][j] = oldBalance + interest;
}
}
// print one row of interest rates
for(int j=0; j<interestRate.length; j++)
System.out.printf("%9.0f%%",100*interestRate[j]);

System.out.println();

// print balance table
for(double[] row: balances)
{

//print table row
for(double b: row)
System.out.printf("%10.2f",b);

System.out.println();
}
}}

解决方案 »

  1.   

    public static void mian(String[] args)
    public static void main(String[] args)
      

  2.   

    手动输入的 ?不行就在创建class的时候 ,把main的选项也给带上 ,反正是测试类的
      

  3.   

    main函数拼错了,如果手动写了,运行的时候报错,还是放到ide里面看看!