0

这是我的第一个 java 程序,我尝试在 Eclipse 和 Netbeans 中启动它。我收到启动错误:“选择不包含主要类型。” 我的主要功能的代码如下。完整代码可从http://www.fractalwebdesigns.com/classes.java下载

    class test {
      public static void main(String[] args) {

    //Checking Account Test 
    CheckingAccount checking1 = new CheckingAccount(); 
        CheckingAccount checking2 = new CheckingAccount();
         CheckingAccount checking3 = new CheckingAccount();
        CheckingAccount checking4 = new CheckingAccount();

    checking1.open(1234);                   //Open a checking account with an account number 1234
    checking2.open(1235);                   //Open a checking account with an account number 1235
    checking3.open(1236);                   //Open a checking account with an account number 1236
    checking4.open(1237);                   //Open a checking account with an account number 1237
    checking1.credit(3000);                 //Credit 3000 to the account 1234
    checking2.credit(200);                  //Credit 200 to the account 1235
    checking3.credit(5000);                 //Credit 5000 to the account 1236
    checking4.credit(2000);                 //Credit 2000 to the account 1237
    checking1.debit(500);                   //Debit 500 from the account 1234
    checking3.debit(300);                   //Debit 300 from the account 1236
    checking4.debit(2500);                  //Debit 2500 from the account 1237
    checking1.readBalance();                //Read the balance of the account 1234
    checking2.readBalance();                //Read the balance of the account 1235
    checking1.readLastDepositAmount();      //Read last deposit amount of the account 1234
    checking4.readLastDepositAmount();      //Read last deposit amount of the account 1237

    //Saving Account Test
    SavingsAccount savings1= new SavingsAccount();
    SavingsAccount savings2= new SavingsAccount();
    SavingsAccount savings3= new SavingsAccount();
    SavingsAccount savings4= new SavingsAccount();

    savings1.open(5431);                    //Open a savings account with an account number 5431
    savings2.open(5432);                    //Open a savings account with an account number 5432
    savings3.open(5433);                    //Open a savings account with an account number 5433
    savings4.open(5434);                    //Open a savings account with an account number 5434
    savings1.credit(2000);                  //Credit 2000 to the account 5431
    savings2.credit(4000);                  //Credit 4000 to the account 5432
    savings3.credit(1000);                  //Credit 1000 to the account 5433 
    savings4.credit(5000);                  //Credit 5000 to the account 5434
    savings3.debit(2000);                   //Debit 2000 from the account 5433
    savings2.credit(1000);                  //Credit 1000 to the account 5432
    savings2.debit(2000);                   //Debit 2000 from the account 5432
    savings2.debit(500);                    //Debit 500 from the account 5432
    savings2.debit(300);                    //Debit 300 from the account 5432
    savings2.debit(600);                    //Debit 600 from the account 5432
    savings2.debit(100);                    //Debit 100 from the account 5432
    savings2.readBalance();                 //Read the balance of account 5432
    savings1.addInterest(.1);               //Add interest to the account 5431 with the interest rate 10%
    savings2.addInterest(.1);               //Add interest to the account 5432 with the interest rate 10%
    savings3.addInterest(.1);               //Add interest to the account 5433 with the interest rate 10%
    savings2.readCumulativeInterest();      //Read the cumulative interest of the account 5432
    savings2.readBalance();                 //Read the balance of account 5432. 
    }
}
4

2 回答 2

1

它在什么样的项目中?它应该是一个 Java 项目。源文件也应该在项目的 Java 构建路径中的源文件夹中。我还建议不要使用“默认”包。

于 2013-03-04T05:03:17.913 回答
0

切换工作区可能会导致此问题。尝试更改您的工作区,然后导入您创建的项目。这对我有用。希望这可以帮助

于 2013-06-10T11:56:30.543 回答