Method to Accept a Deposit

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page   go to next page

Answer:

123 Bob 100
92a-44-33 Kathy Emerson 0

Method to Accept a Deposit

Next, implement the method that accepts a deposit. Deposits will be expressed in cents. The method will have one parameter, the number of cents to be added to the balance. The method will not return a value, so its return type will be void.

class CheckingAccount
{
  // instance variables
  String accountNumber;
  String accountHolder;
  int    balance;

  //constructors
  . . . .

  // methods
  . . . .

  void  ( int  )
  {

    balance =   +  ;
  }

}

Since the return type of the method is void, no return statement is needed. When the method is run, it will automatically return to the place where it was called from after the last statement of the method is executed.

QUESTION 14:

Complete the method by filling in the blanks.