Question

The goal of this assignment is to give you some experience building a program that uses...

The goal of this assignment is to give you some experience building a program that uses objects. You must work in teams of 2 to complete this assignment. You will use the BankAccount class you created in Lab 3 to create a banking program. The program must display a menu to the user to allow the user to select a transaction like deposit, withdraw, transfer, create a bank account, and quit the program. The program should allow a user to perform multiple transactions until they quit the program by selecting the quit option. The program must perform all operations on the BankAccount objects your program will store. The operations must search through the collection of BankAccount objects and find the correct object to perform the operation on. When a user creates an account, your program should create a new BankAccount object with the user's input values and store it in an Array or ArrayList.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find my detailed implementation.

I have tested with Single Bank account object.

You can create array list of Bank Account in test program:

public class BankAccount {

  

   private String name;

   private int accountNumber;

   private int PIN;

   private double balance;

  

   public BankAccount(int accN, int pin) {

       accountNumber = accN;

       PIN = pin;

   }

  

   public BankAccount () {

       name = "Undefined";

       accountNumber = 0;

       PIN = 0;

       balance = 0;

   }

   public String getName() {

       return name;

   }

   public int getAccountNumber() {

       return accountNumber;

   }

   public int getPIN() {

       return PIN;

   }

   public double getBalance() {

       return balance;

   }

   public void setName(String name) {

       this.name = name;

   }

   public void setAccountNumber(int accountNumber) {

       this.accountNumber = accountNumber;

   }

   public void setPIN(int pIN) {

       PIN = pIN;

   }

   public void setBalance(double balance) {

       this.balance = balance;

   }

  

   public void withdrawal(double amount) {

       if(amount <= balance) {

           balance = balance - amount;

       }

   }

   public void deposit(double amount) {

       balance += amount;

   }

  

   public void transferFunds (double amount, BankAccount toBankAccount) {

      

       if(amount >= balance) {

           toBankAccount.setBalance(amount + toBankAccount.getBalance());

           balance -= amount;

       }

      

   }

  

   @Override

   public String toString() {

       return "{id:"+accountNumber+", name:"+name+", pin:"+PIN+", balance:$"+balance+"}";

   }

}

#########

public class BankAccountTest {

   public static void main(String[] args) {

      

       BankAccount myAccount = new BankAccount(526323450, 1234);

       myAccount.setName("Pravesh");

       myAccount.setBalance(345.64);

      

       System.out.println(myAccount);

      

       BankAccount anotherAccount = new BankAccount(); //default constructor

      

       System.out.println(anotherAccount);

   }

}

/*

Sample run:

{id:526323450, name:Pravesh, pin:1234, balance:$345.64}

{id:0, name:Undefined, pin:0, balance:$0.0}

*/

Add a comment
Know the answer?
Add Answer to:
The goal of this assignment is to give you some experience building a program that uses...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • What if you had to write a program that would keep track of a list of...

    What if you had to write a program that would keep track of a list of rectangles? This might be for a house painter to use in calculating square footage of walls that need paint, or for an advertising agency to keep track of the space available on billboards. The first step would be to define a class where one object represents one rectangle's length and width. Once we have class Rectangle, then we can make as many objects of...

  • If you could please assist me with this C# assignment. Screenshots would be greatly appreciated! Create...

    If you could please assist me with this C# assignment. Screenshots would be greatly appreciated! Create a Windows application using C# visual studio that functions like a banking account register. The graphical user interface should initially allow the user to input the account name, number, and initial balance. Ensure that the full name is entered for the customer and that only numeric values are entered for number fields when the Create Account button is selected. Separate the business logic from...

  • need help in Java Now we’ll continue our project by writing a Facebook class that contains an ArrayList of Facebook user...

    need help in Java Now we’ll continue our project by writing a Facebook class that contains an ArrayList of Facebook user objects. The Facebook class should have methods to list all of the users (i.e. print out their usernames), add a user,delete a user, and get the password hint for a user You will also need to create a driver program. The driver should create an instance of the Facebook class and display a menu containing five options: list users...

  • The program needs to be in python : First, create a BankAccount class. Your class should...

    The program needs to be in python : First, create a BankAccount class. Your class should support the following methods: class BankAccount (object): """Bank Account protected by a pin number.""" def (self, pin) : init "n"Initial account balance is 0 and pin is 'pin'."" self.balance - 0 self.pin pin def deposit (self, pin, amount): """Increment account balance by amount and return new balance.""" def withdraw (self, pin, amount): """Decrement account balance by amount and return amount withdrawn.""" def get balance...

  • The purpose of this assignment is to prove that you can build and use an arraylist...

    The purpose of this assignment is to prove that you can build and use an arraylist (which is different than an array). Your program will ask the user to start entering names and to type "Quit" to quit. Each of these names will be stored in an arraylist. (You can assume that no one will be named "Quit".) After they have entered all of the names and typed "Quit" they should receive a list of everything they entered. The program...

  • Java - In NetBeans IDE: •Design an abstract class called BankAccount which stores the balance. –Implement...

    Java - In NetBeans IDE: •Design an abstract class called BankAccount which stores the balance. –Implement a constructor that takes the balance (float). –Provide abstract methods deposit(amount) and withdraw(amount) •Design a class called SavingsAccount which extends BankAccount. –Implement a constructor that takes the balance as input. –It should store a boolean flag active. If the balance at any point falls below $25, it sets the active flag to false. It should NOT allow the balance to fall below $0. –If...

  • C++ Design a class bankAccount that defines a bank account as an ADT and implements the...

    C++ Design a class bankAccount that defines a bank account as an ADT and implements the basic properties of a bank account. The program will be an interactive, menu-driven program. a. Each object of the class bankAccount will hold the following information about an account: account holder’s name account number balance interest rate The data members MUST be private. Create an array of the bankAccount class that can hold up to 20 class objects. b. Include the member functions to...

  • Instructions Using the BCException.java and the BankCustomer.java from the first part of the assignment you will...

    Instructions Using the BCException.java and the BankCustomer.java from the first part of the assignment you will implement a driver class called Bank.java to manipulate an ArrayList of BankCustomer objects. Your code should read bank customers’ information from the user. It will then create a bank customer objects and add them to an arraylist in a sorted fashion (sorted by account number). The arraylist should be sorted in ascending order at all times. The arraylist should not contain null objects at...

  • Python 3.7 to be used. Just a simple design a program that depends on its own. You should also not need to import anythi...

    Python 3.7 to be used. Just a simple design a program that depends on its own. You should also not need to import anything. No code outside of a function! Median List Traversal and Exception Handling Create a menu-driven program that will accept a collection of non-negative integers from the keyboard, calculate the mean and median values and display those values on the screen. Your menu should have 6 options 50% below 50% above Add a number to the list/array...

  • Requesting help with the following C Program: DESIGN and IMPLEMENT a menu driven program that uses...

    Requesting help with the following C Program: DESIGN and IMPLEMENT a menu driven program that uses the following menu and can perform all menu items: Enter a payroll record for one person Display all paycheck stubs Display total gross payroll from all pay records. Quit program The program will reuse the DATE struct from the previous assignment.  You should also copy in the functions relating to a DATE. The program will create a PAYRECORD struct with the following fields: typedef struct...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT