0

This is my first java program and I have tried to launch it in Eclipse and Netbeans. I receive the launch error: "Selection does not contain a main type." The code of my main function is below. The full code can be downloaded from 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. 
    }
}
vijay
  • 2,646
  • 2
  • 23
  • 37
beverts312
  • 65
  • 1
  • 9
  • 1
    i think make the class as public – PSR Mar 04 '13 at 04:58
  • possible duplicate of [Error: Selection does not contain a main type](http://stackoverflow.com/questions/16225177/error-selection-does-not-contain-a-main-type) – jww Sep 30 '14 at 05:49

2 Answers2

1

What kind of project is it in? It should be a Java Project. The source file should also be in a Source Folder in the project's Java Build Path. I'd also suggest not using the "default" package.

0

Switching workspace may cause this problem. Try changing your workspace, then import the project that you've created. That worked for me. hope this helps

ioniizer
  • 1
  • 1
  • 1