这是我的第一个 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.
}
}