Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Project #1 This project will involve creating a BankAccount class with the following properties below: The BankAccount class will be used to set up multiple

Project #1 This project will involve creating a BankAccount class with the following properties below: The BankAccount class will be used to set up multiple client accounts (different name & ID), it will also be used to keeps track of a user's available balance, along with the number of transactions (deposits and/or withdrawals) which are made. public class BankAccount { Private String name private String id; private double balance; private int numTransactions; // Accessors and Mutator functions.... // Additional methods // Deposit - Adds amount to balance. Also counts as 1 transaction. public void deposit(double amount) // Subtracts amount from balance if user has enough money. Counts as 1 transaction. public void withdraw(double amount) // Remember to verify client has sufficient funds prior to withdrawal, and if not 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() and withdraw(). //Example of using this class when using the default contructor: BankAccount savings = new BankAccount(); savings.setName ("Jimmy"); // can also use this method when the default constructor is used. savings.setId(12345); // can also 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 transactions System.out.println("Number of Transactions = "+savings.getNumTransactions()); // Example using 2 parameter constructor BankAccount 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 transactions System.out.println("Number of Transactions = "+savings2.getNumTransactions()); 3) Create two constructors for your class: the default and 3 parameter constructors. The three parameter constructor will allow a user to set the name, id and initial balance when instantiating the object. 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 testing screenshots in ONE MS Word file. Therefore each student should upload ONLY 3 files: 2 JAVA files and 1 MS Word document (testing code). Any files other than these, will not be looked at and will not be graded. 6) Some code requirements: a) Withdrawal amount should be tested to ensure there are sufficient funds present. b) setBalance should check whether the deposited amount is in the valid range 0-10,000 (inclusive) c) setNumTransactions should not allow setting to a negative value. d) Don't worry about testing for valid name, id. Rubric grading criterior, ensure code: has appropriate comments, uses good coding styles (proper indenting), proper naming conventions, no literals (use Constants) as has been shown in class. has been tested properly. Note that this assignment is to be worked on individually and not in groups.

can anyone pls answer this beofore 2/2 please

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

Step: 3

blur-text-image

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

More Books

Students also viewed these Databases questions

Question

4. Devise an interview strategy from the interviewers point of view

Answered: 1 week ago