Question: Introduction Through this In-class exercise, you will practice - Creating a class with data attributes, constructors, and methods - Instantiating the class you created and

 Introduction Through this In-class exercise, you will practice - Creating aclass with data attributes, constructors, and methods - Instantiating the class you

Introduction Through this In-class exercise, you will practice - Creating a class with data attributes, constructors, and methods - Instantiating the class you created and calling its methods Submission Instructions This lab will be submitted through GitHub. Start by accepting the GitHub Classroom homework through the following link: Prompt 1 You have been hired by a bank to develop a new software system to manage their customers' accounts. The bank has asked you to create a class to represent a bank account. Requirements: - The class should be named BankAccount. - The class should have two attributes, client name (string) and balance (float). To instantiate (create an object) this class, the client name must be provided. An initial value for balance can either be provided during instantiation or it can be set to a default value so 0 . - The class should have the following methods: - deposit(amount) : deposits the specified amount into the account - withdraw(amount) : withdraws the specified amount from the account - get_balance( ) : returns the current balance of the account - get_owner( ) : returns the name of the client name - The deposit and withdraw methods should update the balance attribute accordingly. - Create another class TestBankAccount with main( ) method to test BankAccount - Run the following tests in main ( ) I/ create 2 accounts BankAccount account 1= new BankAccount("Adam Smith"); BankAccount account2 = new BankAccount("Jackie Smith",100); // deposit some money account1.deposit(100.0); account2.deposit(100.0); // withdraw some money account1.withdraw(50.0); account2.withdraw(20.0); // print account info System.out.println(account1.get_owner()); // should print "Adam Smith" System.out.println(account1.get_balance()); / should print 50.0 System.out.println(account2.get_owner()); // should print "Jackie Smith" System.out.println(account2.get_balance()); / should print 180.0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!