Creating Instance Methods and Driver Class

Monday, May 5, 2014

Objective: Create a class with instance data and instance methods.

Specifications: Create a BankAccount class. It should contain the following information, stored in instance variables:

First name: The customer’s first name.

Last name: The customer’s last name

Balance: The amount of money the customer has in the account.

It should have the following methods:

BankAccount(String firstName, String lastName, double openingBalance)

This constructor creates a new BankAccount

public String firstName()

Returns the customer’s first name

public String lastName()

Returns the customer’s last name

public double balance()

Returns the customer’s account balance

Create a driver to test your class. Create several accounts and verify that the first name, last name, and balance methods work properly.

I don't know if I did it correctly because I get no output at all...If I did it wrong please correct me. Thanks! Here is the code below.

public class BankAccount {
String firstName, lastName;
double balance;

public BankAccount(String firstName, String lastName,double openingBalance){

public String firstName(){

public String lastName(){

public double balance(){

Below is my "Driver" class

public class Driver {

static BankAccount acc1;

public static void main (String[] args){

acc1 = new BankAccount ("John","Tiger", 200);