Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Account that contains: balance: double data field date: Date data field. Use Date class from the java.util package accountNumber: long data field. You should generate
Account that contains:
- balance: double data field
- date: Date data field. Use Date class from the java.util package
- accountNumber: long data field. You should generate this value randomly. The account number should be 9 digits long. You can use the random method from java Math class.
- annualInterestRate: double data field.
- customer: customer data field.
- The accessor and mutator methods for balance, annualInterestRate, date, and customer.
- The accessor method for accountNumber.
- A constructor that creates an account with the specified customer, balance, and interest rate. Also, it should generate the account number and the current date.
- A method called getMonthlyInterestRate that returns the monthly interest rate. Monthly Interest Rate is the annualInterestRate / 12.
- A method called getMonthlyInterest that returns the monthly interest. Monthly interest is the balance * monthlyInterestRate.
- A method called generateAccountNumber that returns a 9 digit number.
- A method called deposit that takes a parameter of type double. This method will add the value of the parameter to the balance. Make sure not to accept any negative values.
- A method called withdraw that takes a parameter of type double. This method will subtract the value of the parameter from the balance. Make sure not to accept any negative values or values greater than existing balance.
- Override toString method. This method should return all the information about this account.
Customer class that contains:
- firstName: String data field.
- lastName: String data field
- address: String data field
- age: int data field
- The accessor and mutator methods for firstName, lastName, age, and address.
- id: int data field. The first customer should have an id of 32000 and for any new customer add 10.
- Constructor that creates an customer with the specified first name, last name, address, and age. Also, it should generate the customers id.
- Override toString method. This method should return all details about this account (firstName, lastName, address, id, and age)
- Override equals method. This method should return true if the calling object is equal to the other object.
Write a test program that creates an BankAccount object. Make sure to test all the methods in both the BankAccount and Customer objects.
Note: You dont have to use Scanner to read the users input. It suffice to hard code the values in the driver. Also, make sure that all your mutator (setter) methods validate the inputs.
Here is the output that you should get if you run your program with the Driver below:
public static void main(String[] args{ double balance = 1330; double interestRate = 4.5; Customer customer1 = new Customer"Sarah", "Smith", "319 grand ave", 24); System.out.println("customer-1 toString: " + customer.toString); Customer customer2 = new Customerlohn", "Smith", "12 nicollect", 34); System.out.println("customer-2 toString: " + customer2.toString); BankAccount account = new BankAccount(customeri, balance, interest Rate); System.out.println("Current Balance:" + account.getBalance(); account.deposit(200); System.out.println("Current Balance:" + account.getBalanceD): System.out.println("Account Number:" + account.getAccount Number(); System.out.println"Account Created date:" + account.getDate() System.out.println("Customer ID:* + account.getCustomer().getle)); System.out.println("Monthly inerest Rate:" + account.getMonthlyInterestRate() System.out.println("Monthly interest: " + account.getMonthlyInterest(): System.out.println("Current Balance:" + account.getBalance(); account withdraw 300); System.out.println("Monthly interest: " + account.get MonthlyInterest(): customer-1 toString: Customer [ID= 32000 FirstName=Sarah LastName=Smith Age= 24 Address=319 grand ave] customer-2 toString: Customer [ID= 32010 FirstName=John LastName=Smith Age= 34 Address=12 nicollect] Current Balance: 1330.0 Current Balance: 1530.0 Account Number: 411341391 Account created date: Fri 1 Jun 18 Customer ID: 32000 Monthly Inerest Rate: 0.375 Monthly Interest: 5.7375 Current Balance: 1530.0 Monthly Interest: 4.6125 Account-1 toString output: BankAccount [Balance= 1230.0 date= Fri Jun 01 19:13:54 CDT 2018 Account Number= 411341391 InterestRate= 4.5 Customer [ID= 32000 FirstName=Sarah LastName=Smith Age= 24 Address=319 grand ave]Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started