Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

a) Create a class name NameAndAddress that contains fields for name and address. The class should have A constructor that accepts parameters for each

a) Create a class name NameAndAddress that contains fields for name and address. The class should have • A constructor that accepts parameters for each field. • Get methods for each field. • A display method to display name and address

 

b) Create a class named Person that contains the fields of the NameAndAddress class and the person’s date of birth (LocalDate) type. The class should have • A constructor that accepts parameters for each field. • Get methods for each field. • A display method to display a person’s details including name, address and date of birth.

 

c) Create a class named Account that contains fields for account ID, balance, an object of Person class type and the date (Local Date) type the account was created. The class should have • A default constructor. • A constructor that accepts parameters for all required fields. • Set and get methods for all required fields. 2 • A method named withdraw to withdraw a specified amount from the account. • A method named deposit to deposit a specified amount to the account. • A display method to display all the details.

 

d) To simulate an ATM machine, create an application or class called ATM Machine and generate three accounts (represented by three objects of the Account class) with unique IDs and initial balances (inputted by the user). Ensure that the user input for ID, birth month and date is valid. An ID is considered valid if it is between 1111 and 9999 inclusive. Once the three accounts are created, prompt the user to input an ID to search for. If the ID entered is invalid/not found, request the user to enter the correct ID. After inputting the correct ID, display the main menu (for searched account) with the following options: 1 for viewing the current balance, 2 for withdrawing money, 3 for depositing money, 4 for viewing account details, and 5 for exiting the main menu. If the user chooses to exit, the application should exit by displaying “Goodbye”.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

a NameAndAddress class java public class NameAndAddress private String name private String address public NameAndAddressString name String address thisname name thisaddress address public String getNa... 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

Java Programming

Authors: Joyce Farrell

10th Edition

0357673425, 9780357673423

More Books

Students also viewed these Programming questions