This project will involve creating a BankAccount class with the following properties below: The BankAccount class will b

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

This project will involve creating a BankAccount class with the following properties below: The BankAccount class will b

Post by answerhappygod »

This project will involve creating a BankAccount class with thefollowing properties below:The BankAccount class will be used to set up multiple clientaccounts (different name & ID), it will also beused to keeps track of a user's available balance, along with thenumber of transactions (deposits and/or withdrawals) which aremade.
public class BankAccount { Private String name private String id; private double balance; private int numTransactions;
// Accessors and Mutatorfunctions....
// Additional methods // Deposit - Adds amount to balance. Also countsas 1 transaction. public void deposit(double amount) // Subtracts amount from balance if user hasenough money. Counts as 1 transaction. public void withdraw(double amount) // Rememberto verify client has sufficient funds prior to withdrawal, and ifnot output a message.}
1) Please write the Accessor (Getters) and Mutators (Setters)methods for the 4 instance variables above. 2) Also create the method definitions for the methods deposit() andwithdraw().
//Example of using this class when using the defaultcontructor:BankAccount savings = new BankAccount();savings.setName ("Jimmy"); // can also use this method whenthe default constructor is used.savings.setId(12345); // canalso use this method when the default constructor is used.savings.setBalance(50.00);
savings.deposit(10.00);savings.deposit(50.00);savings.deposit(10.00);savings.deposit(70.00); savings.withdraw(100.00);System.out.println("Balance = "+savings.getBalance()); // Balance = $90, with 5 transactionsSystem.out.println("Number of Transactions ="+savings.getNumTransactions());
// Example using 2 parameter constructorBankAccount savings2 = new BankAccount("John", 6789, 100.00);
savings2.deposit(20.00);savings2.withdraw(10.00);System.out.println("Balance = "+savings2.getBalance()); // Balance = $110, with 2 transactionsSystem.out.println("Number of Transactions ="+savings2.getNumTransactions());
3) Create two constructors for your class: the default and 3parameter constructors. The three parameter constructor will allow a user toset the name, id and initial balance when instantiating theobject.
4) Please create the the BankAccount class in one java file(BankAccount.java) and the test/demo with main in a second java file (BankAccountDemo.java). 5) Please test all methods for the class and insert your testingscreenshots in ONE MS Word file. Therefore each student should upload ONLY 3 files: 2JAVA files and 1 MS Word document (testing code). Any files other than these, will not be looked at andwill not be graded.
6) Some code requirements: a) Withdrawal amount should be tested toensure there are sufficient funds present. b) setBalance should check whether thedeposited amount is in the valid range 0-10,000 (inclusive) c) setNumTransactions should not allowsetting to a negative value. d) Don't worry about testing for validname, id.
Rubric grading criterior, ensure code: has appropriatecomments, uses good coding styles(proper indenting), proper naming conventions, no literals (useConstants) as has been shown in class. has been tested properly.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply