Problem Description: This program is designed to extend the Account class from h
ID: 3535158 • Letter: P
Question
Problem Description:
This program is designed to extend the Account class from homework #3. From our previous efforts, the Account class was defined to model a bank account. An account has the properties account number, balance, annual interest rate and date created. It also includes methods to deposit and withdraw funds.
· Start a new Java project within Eclipse for HW#4.
o Add the Account Java file from your previous efforts.
o All java files must be in the package BankAccount.
· Create two subclasses (i.e. child classes) for checking and savings accounts that extend the parent class of Account.
o A checking account has an overdraft limit, but a savings account cannot be overdrawn.
Your constructors for both Checking and Savings Accounts should take in 3 parameters, and call the Account Constructor, which takes in only two parameters(int id, double balance). The new CTORS should call the parent CTOR, as well as store the new third parameter for initial interest rate (int id, double balance, double intRate).
· Draw the UML diagram for the classes (3 Classes). Implement the classes. Write a test program that creates objects of Account, SavingsAccount and CheckingAccount.
o Invoke the toString () functions for each of the classes after instantiation.
o Implement an Exception for trying to withdraw more than the Savings account has in its balance.
o Implement a GUI dialog box to ask the user for an account number (must be an int), a balance (greater than or equal to zero, and must be a double), and then a starting interest rate (must be a double, either in the form of 4.5% or .045 as a percentage). Once you have the information from the user, you must then put a dialog box back out to the user stating the account was created – account number, initial balance, interest rate and date created.
§ Perform once to create a checking account.
this is my HW#3
import java.util.Date;
public class accountclass {
public static void main(String[] args) {
//create an instance object of class Stock
Account myAccount = new Account(1122, 20000.00, 0.045);
myAccount.withdraw(2500.00);
myAccount.deposit(3000.00);
//display balance, monthly interest and date of account
System.out.println("Balance: " + myAccount.balance);
System.out.println("Monthly Interest: " + myAccount.getMonthlyInterestRate());
//System.out.println("Account created on: " + myAccount.dateCreated);
java.util.Date dateCreated = new java.util.Date();
System.out.println("Account created on: " + dateCreated.toString());
}
}
class Account {
int id;
double balance;
double annualInterestRate;
Date dateCreated;
//no arg constructer
Account() {
id = 0;
balance = 0.0;
annualInterestRate = 0.0;
}
//constructor with specific id and initial balance
Account(int newId, double newBalance) {
id = newId;
balance = newBalance;
}
Account(int newId, double newBalance, double newAnnualInterestRate) {
id = newId;
balance = newBalance;
annualInterestRate = newAnnualInterestRate;
}
//accessor/mutator methods for id, balance, and annualInterestRate
public int getId() {
return id;
}
public double getBalance() {
return balance;
}
public double getAnnualInterestRate() {
return annualInterestRate;
}
public void setId(int newId) {
id = newId;
}
public void setBalance(double newBalance) {
balance = newBalance;
}
public void setAnnualInterestRate(double newAnnualInterestRate) {
annualInterestRate = newAnnualInterestRate;
}
//accessor method for dateCreated
public void setDateCreated(Date newDateCreated) {
dateCreated = newDateCreated;
}
//define method getMonthlyInterestRate
double getMonthlyInterestRate() {
return annualInterestRate/12;
}
//define method withdraw
double withdraw(double amount) {
return balance -= amount;
}
//define method deposit
double deposit(double amount) {
return balance += amount;
}
}
Explanation / Answer
Hey, I can do this. If you give me some time. I am not going to charge anything extra. If you can give me a day, I can get back to you on this with 100% executable code. If you are fine with this, meet me on my mail. Its pratapudaysingh@gmail.com. And dont worry. be assured. I ll do it for you
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.