Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In a Netbeans project Create a class Account representing a bank account and a class Customer, representing a bank customer. Give Account two public instance

In a Netbeans project

Create a class Account representing a bank account and a class Customer, representing a bank customer.

Give Account two public instance variables: bal, a double representing a balance, and owner, a Customer.

Write a toString() for Account that returns the balance with a dollar sign in front of it (it doesn't show Customer info).

Give Customer two public instance variables: name, a String, and acct, an Account.

Write a toString() for Customer that returns the name with "Account Owner: " in front of it (not showing Account info)

Create a class with a main, and in main create one Account and one Customer. Set their instance variables to point to each other so the Customer is the owner of the Account and the Account is the acct of the Customer.

Set the balance using the Customer variable and the name using the Account variable., then print them.

Part B

The following code is not useful; it does several silly things; but it is the shortest code I could write with examples of most of the things people tend to get confused about.

1 package memory; 2 public class BankTrace { 3 4 public static void method2(Customer cust1, Customer cust2) { 5 cust2 = cust1.acct.own; 6 cust1.acct = new Account(); 7 cust2.acct.bal = 3999.50; 8 cust2 = new Customer(); 9 cust2.acct = new Account(); 10 cust2.acct.bal = 77.0; 11 } 12 13 public static void method1(Customer cust, Account money, double bal) { 14 money.bal = bal; 15 bal = 99.33; 16 money.own = cust; 17 cust.acct = money; 18 Account newAct = new Account(); 19 newAct.bal = 88.88; 20 method2(cust, newAct.own); // not a typo I promise 21 } 22 23 public static void main(String[] args) { 24 Customer customerJoan = new Customer(); 25 Account bankAccount = new Account(); 26 bankAccount.balance = 828.00; 27 double x = 4403.20; 28 29 method1(customerJoan, bankAccount, x); 30 31 } 32 }

Questions (in a Word document attached to your submission, NOT hidden in your zipped directory): Consider how the above code would run with your classes; do not actually run it.

At the end of this program:

  1. For the local variable in main customerJoan, is customerJoan.acct null? If not, what value is in customerJoan.acct.bal?
  2. For the local variable in main bankAccount, what value is in bankAccount.bal?
  3. How many customer objects total were created?
  4. How many account objects total were created?

Explain briefly (noting line numbers), how you got your answers.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 25th European Conference Adbis 2021 Tartu Estonia August 24 26 2021 Proceedings Lncs 12843

Authors: Ladjel Bellatreche ,Marlon Dumas ,Panagiotis Karras ,Raimundas Matulevicius

1st Edition

3030824713, 978-3030824716

More Books

Students also viewed these Databases questions