Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Question regarding to inheritance with methods within a class

  1. #1
    Junior Member
    Join Date
    Feb 2018
    Thanked 0 Times in 0 Posts

    Default Question regarding to inheritance with methods within a class

    Hello all,

    I'm taking my first programming class in JAVA, and am very much lost in method and inheritance. Can someone shed some light...

    I created a class for Customer and BankAccount, but am confused as of how to define methods under BankAccount..

    I appreciate any of your helps.


    Write a Java program for a simple bank account.

    You shall define a Customer class. A customer has a first name, last name, and social security number. The social security number is a String variable and must comply with this format: xxx-xx-xxxx where 'x' is a digit between 0-9. If a customer is supplied an invalid ssn, a message must be printed that the SSN of the customer is invalid; however, it will create the bank account regardless.

    You shall define a BankAccount class. A BankAccount has a customer, account number, and a balance. A bank account can be opened with any amount of initial deposit. For each bank account, a 10 digit random account number must be created. Bank account shall define the following methods: deposit, withdraw. applyInterest, and checkBalance.

    Every time there is a deposit or withdrawal, the amount and current balance should be displayed. One cannot withdraw more than the funds available in the account.

    You shall define two types of bank accounts: Checking Account and Saving Account. Each account accrues interest. A saving account accrues 5% fixed interest and a checking account accrues 2% for any amount in excess of $10000 (For example, if there is $11000 in the checking account, the interest is only applied to $1000).

    You shall define the BankMain class that defines the main method. You can use the “main” method shown below to test your application. The expected output is also provided.

    public class BankMain {

    public static void main(String[] args) {

    CheckingAccount acct1 = new CheckingAccount("Alin", "Parker", "123-45-6789", 1000.0f);

    CheckingAccount acct2 = new CheckingAccount("Mary", "Jones", "987-65-4321", 500.0f);

    SavingAccount acct3 = new SavingAccount("John", "Smith", "1233-45-6789", 200.0f);












    =================== This is the expected output =======================

    Successfully created account for Alin Parker Account Number 3364673506
    Alin Parker, Balance $1000.0
    Successfully created account for Mary Jones Account Number 6221275878
    Mary Jones, Balance $500.0
    Successfully created account for John Smith. Inavlid SSN!
    Successfully created account for John Smith Account Number 7091028094
    John Smith, Balance $200.0
    Alin Parker deposited $22000.0. Current balance 23000.0
    Mary Jones deposited $12000.0. Current balance 12500.0
    Alin Parker withdrew $2000.0. Current balance 21000.0
    Mary Jones withdrew $1000.0. Current balance 11500.0
    Alin Parker, Balance $21220.0
    Mary Jones, Balance $11530.0
    Unable to withdraw 30000.0 for Alin Parker due to insufficient funds

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Eastern Florida
    Thanked 2,491 Times in 2,442 Posts

    Default Re: Question regarding to inheritance with methods within a class

    I created a class for Customer and BankAccount
    Where is the code that you are working on?
    Please post your code with some specific questions about your problems.

    Please edit your post and wrap your code with code tags:


    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. [SOLVED] Help with objects, methods, and class inheritance.
    By Gingerbread Fetus in forum Object Oriented Programming
    Replies: 3
    Last Post: October 18th, 2013, 09:02 AM
  2. I need some help with inheritance methods.
    By 13078 in forum Object Oriented Programming
    Replies: 1
    Last Post: December 31st, 2012, 12:14 PM
  3. Java and Flickr - Help with Inheritance between Main Class and sub-class
    By thientanchuong in forum What's Wrong With My Code?
    Replies: 10
    Last Post: December 14th, 2012, 07:29 PM
  4. display methods with inheritance
    By ddotreprah in forum Object Oriented Programming
    Replies: 2
    Last Post: November 20th, 2011, 11:06 PM
  5. Replies: 7
    Last Post: July 21st, 2011, 02:29 PM