A good answer might be:

  void display()
  {
    System.out.println(  accountNumber + "\t" + accountHolder + "\t" +  balance );
  }

(The string "\t" tells the compiler that you want the tab character.)


Using the display() Method

Since this method is a member of the class CheckingAccount, the member data can be reached by using just the variable name (like accountNumber) without any need of the "dot operator" needed outside of the class (like account1.accountNumber used in the main method of the other class.)

Another nice thing to do is to use the tabulation character "\t" to align the output better. When the display() has been defined, the testing program can be more easily written:

class CheckingAccount
{
  . . . . (Now including the display() method.)
}

class CheckingAccountTester
{
  public static void main( String[] args )
  {
    CheckingAccount account1 = new CheckingAccount( "123", "Bob", 100 );

    account1.display() ;
    account1.processDeposit( 2000 );
    account1.processCheck( 1500 );
    account1.display() ;

  }
}

QUESTION 18:

With this nice, new scaffolding in place, you must surely be eager to do further testing of the program. Add statements after the old statements in the test program that: