Question: Design a Java program that simulates bank accounts. Your main function should contain a menu to allow the user to create, modify, retrieve (display) and

Design a Java program that simulates bank accounts. Your main function should contain a menu to allow the user to create, modify, retrieve (display) and delete a bank account.

To modify/retrieve a bank account you need to enter either a last name or SSN.

You need to design a class for Date, a class for person, and a class for BankAccount. A Person inherites from date as each person has

a birth date, in addition to first name, last name, address and SSN.

A BankAccount has a maximum of three holders (person) and a balance, an interest rate, opening date, last date interest was payed.

A method to compute the interest.

Date and person class is provided below

////////////////////////////////////////////////////////////////////////////////////////////////

public class Date { private int day; private int month; private int year; private static int [] Days = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; public Date() { day = 1; month = 1; year = 1970; } public Date(int m, int d, int y){ day = d; month = m; year = y; } public Date(String s) { setDate(s); } public void setDate(String s) { if (s.contains("/")) { //the format is mm/dd/yyyy String[] result = s.split("/"); month = Integer.parseInt(result[0]); day = Integer.parseInt(result[1]); year = Integer.parseInt(result[2]); } else if(s.indexOf('-') > 0) { String[] result = s.split("-"); year = Integer.parseInt(result[0]); month = Integer.parseInt(result[1]); day = Integer.parseInt(result[2]); }else { System.out.println("Invalid date"); } } public String toString() { String st = month + "/" + day + "/" + year; return st; } //getters public int getDay() { return day; } public int getMonth() { return month; } public int getYear() { return year; } //setters public void setYear(int y) { year = y; } public void setMonth(int m){ if(m<1 || m> 12) { System.out.println("Invalid month"); return; } } public void setDay(int d) { if(isLeap() && month == 2){ if (d < 1 || d > 29){ System.out.println("Invalid day"); return; } } if(d < 1 || d > Days[month]) { System.out.println("Invalid day"); return; } day = d; } public boolean isLeap(){ if((year%4 == 0 && year%100 != 0) || year%400 == 0) return true; return false; } }
////////////////////////////////////////////// import java.util.Scanner; public class Person extends Date { private String fName, lName, Address; private int ssn; //default constructor public Person() { //we call the default constructor of Date super(); //set all provate members to default values fName = "unknown"; lName = "unknown"; Address = "unknown"; ssn = 0; } public Person (String dob, String fn, String ln, String addr, int s) { super(dob); fName = fn; lName = ln; Address = addr; ssn = s; } //getters public String getFName() { return fName; } public String getLName() { return lName; } public String getAddress() { return Address; } public int getSSN() { return ssn; } //setters public void setFName(String n) { fName = n; } public void setLName(String n) { lName = n; } public void setAddress(String a){ Address = a; } public void setSSN(int n) { ssn = n; } public void setDOB(String s){ this.setDate(s); } public void setDOB(int m, int d, int y){ String date = m+"/"+d+"/"+y; this.setDate(date); } public String toString() { String st = "DoB: " + super.toString() + ", SSN: " + ssn + ", First Name: " + fName + ", Last Name: " + lName + " Address: "+ Address; return st; } public void read(Scanner in) { System.out.println("enter your birth day (mm/dd/yyyy):"); String d = in.nextLine(); this.setDate(d); System.out.println("enter SSN: " ); this.setSSN(in.nextInt()); this.setFName(in.nextLine());//the carriage return will be still inthe buffer //nextLinen if invoked will read one character (carriage return) and return //we need to empty the buffer before reading a string, we read a line for nothing System.out.println("enter first name: " ); this.setFName(in.nextLine()); System.out.println("enter last name: " ); this.setLName(in.nextLine()); System.out.println("enter address: " ); this.setAddress(in.nextLine()); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!