Create an Inheritance hierarchy that a bank may use to represent customer's bank accounts (Checking and Savings), this includes a GUI user interface that allows user to login, and deposit or withdraw, and application to display the transaction and final balance.
All the bank customers can: - Create a new account - Deposit (Credit) money into their account and/or withdraw (debit) money from their account. - Application should expect user to login to their account using login/password Create necessary classes and Java application to use and test these classes. Savings Accounts - earn interest on the money in the account. Checking accounts - charges a fixed fee for each transaction the customer makes. Create base class Account, with derived classes SavingsAccount and CheckingAccount that inherit from Account Account: contains - initialBalance Constructors, getter/setters validation for initialBalance, credit() - make input is correct and positive and credit the account debit() - make sure there is enough money, otherwise it should left unchanged Account:SavingsAccount Inherit from Account additional property called interestRate (percentage assigned to account) SavingsAccount Constructor should receive initialBalance, value for interestRate method calculateInterest() that returns the amount of interest CheckingAccount Inherit from Account additional instance variable for fee charged per transaction Constructor should receive the initialBalance and fee amount Should redefine debit () and credit () to take under consideration the fee charged
Now create and application that creates objects of each class to test each method. Add interest to the savingsAccount object by first invoking its caculateInterest () method, then pass the returned interest amount to the object's credit () method. Develop a polymorphic banking application using the Account hierarchy. Create an array of Account references to SavingsAccount and CheckingAccount objects. For each account in the array, allow the user to specify an amount of money to withdraw from the account using method debit() and an amount to deposit into the account using the method deposit(). As you process each Account, determine its type. If an account is a SavingsAccount, calculate the amount of interest owed to the Account using method calculateInterest(), then add the interest to the account balance using method credit().
After processing an Account, print the updated balance obtained by using the getBalance() from the base class. Interactively ask the user for information for each account and then print the result for each account. Create Custom Exception NegativeBalanceException for the cases when user try to withdraw amount beyond available balance.
In order to get the complete point for the assignment, make sure you follow the coding guidelines provided. Submit a copy of the following items to Blackboard: A copy of the source code Captured output for each program (use < prt sc> to capture the output) UML Diagram for assignment, make sure to use software to do the flow charts (use correct symbols) Make sure your code if well commented Make sure your code is indented correctly Make sure each listing has a prologue at the beginning (Description of your Application) Refer to the Guidelines and coding standards provided in the external links No late assignment will be accepted unless it has been arranged previously This applies to all the homework you turn in Turn in a zipped file that contains all the necessary files
-This is in Java
-Need a GUI component too
package GUI;
import java.awt.event.*;
import javax.swing.*;
// Defines a super class Account
class Account
{
// Instance variable to store account information
double initialBalance;
String userName;
String password;
// Parameterized constructor to assign parameter values to instance variable
Account(String un, String ps, double balance)
{
initialBalance = balance;
userName = un;
password = ps;
}// End of parameterized constructor
// Method to return balance
double getBalance()
{
return initialBalance;
}// End of method
// Method to credit amount
// Returns true for success otherwise return false
boolean credit(double amt)
{
// Checks if the amount is greater than 0
// Add the amount to balance
// return true for success
if(amt > 0.0)
{
initialBalance += amt;
return true;
}// End of if condition
// Otherwise return false for failure
else
return false;
}// End of method
// Method to debit amount
// Returns -1 if amount is zero or less
// Returns 0 if amount is greater than balance
// Returns 1 for success
int debit(double amt)
{
// Checks if amount is less than or equals to 0
if(amt <= 0.0)
return -1;
// Otherwise checks if amount is greater than balance
else if(amt > initialBalance)
return 0;
// Otherwise valid amount, update the balance
else
{
initialBalance -= amt;
return 1;
}// End of else
}// End of method
}// End of class Account
// Defines a class SavingsAccount derived from class Account
class SavingsAccount extends Account
{
// Instance variable to store interest rate
double interestRate;
// Parameterized constructor to assign parameter values to instance variable
SavingsAccount(String un, String ps, double balance, double rate)
{
// Calls the base class parameterized constructor
super(un, ps, balance);
interestRate = rate;
}// End of parameterized constructor
// Method to calculate and return interest
double calculateInterest()
{
return initialBalance * interestRate / 100.0;
}// End of method
}// End of class SavingsAccount
// Defines a class CheckingAccount derived from class Account
class CheckingAccount extends Account
{
// Instance variable to store fee charged
double feeCharged;
// Parameterized constructor to assign parameter values to instance variable
CheckingAccount(String un, String ps, double balance, double charge)
{
// Calls the base class parameterized constructor
super(un, ps, balance);
feeCharged = charge;
}// End of parameterized constructor
// Overload method to debit amount
int debit(double amt)
{
// Calls the base class method
super.debit(amt);
// Subtracts charge from balance
initialBalance -= feeCharged;
return 1;
}// End of method
// Overload method to credit amount
boolean credit(double amt)
{
// Calls the base class method
super.credit(amt);
// Subtracts charge from balance
initialBalance -= feeCharged;
return true;
}// End of method
}// End of class CheckingAccount
// Driver class AccountGUI definition
public class AccountGUI
{
// For maximum record
static final int MAX = 10;
// Component and container object declared
JFrame jf;
JPanel accountP, transactionP, mainP;
JRadioButton savingR, currentR;
ButtonGroup bg;
JButton creditB, debitB;
// Declares an array of object of class SavingsAccount and CheckingAccount
SavingsAccount sa[];
CheckingAccount ca[];
// Account record counter
int saCounter, caCounter;
// Default constructor definition
AccountGUI()
{
// Creates the array of object
sa = new SavingsAccount[MAX];
ca = new CheckingAccount[MAX];
// Initializes the counter
saCounter = caCounter = 0;
// Creates the component and container
jf = new JFrame("BANK");
accountP = new JPanel();
transactionP = new JPanel();
mainP = new JPanel();
savingR = new JRadioButton("Create Saving Account");
currentR = new JRadioButton("Create Current Account");
bg = new ButtonGroup();
bg.add(savingR);
bg.add(currentR);
creditB = new JButton("Credit");
debitB = new JButton("Debit");
// Adds the component to panel
accountP.add(savingR);
accountP.add(currentR);
transactionP.add(creditB);
transactionP.add(debitB);
// Adds the panel to main panel
mainP.add(accountP);
mainP.add(transactionP);
// Adds the main panel to frame
jf.add(mainP);
// Sets the frame visible property to true
jf.setVisible(true);
// Set the size of the frame to width 400 and height 200
jf.setSize(400, 200);
jf.setLocationRelativeTo(null);
// Registers action listener to saving radio button using anonymous class
savingR.addActionListener(new ActionListener()
{
// Overrides the actionPerformed() method of ActionListener interface
public void actionPerformed(ActionEvent ae)
{
JOptionPane.showMessageDialog(jf, "Creating Saving Account", "",
JOptionPane.INFORMATION_MESSAGE);
// Accepts user name and password
String un = JOptionPane.showInputDialog("Enter user name: ");
String pa = JOptionPane.showInputDialog("Enter password: ");
// Accepts initial balance
double bal = Double.parseDouble
(JOptionPane.showInputDialog("Enter initial balance$ "));
// Accepts rate of interest
double intr = Double.parseDouble
(JOptionPane.showInputDialog("Enter Interest Rate: "));
// Creates a saving account using parameterized constructor
// Increase the counter by one
sa[saCounter++] = new SavingsAccount(un, pa, bal, intr);
}// End of method
});// End of anonymous class
// Registers action listener to current radio button using anonymous class
currentR.addActionListener(new ActionListener()
{
// Overrides the actionPerformed() method of ActionListener interface
public void actionPerformed(ActionEvent ae)
{
JOptionPane.showMessageDialog(jf, "Creating Checking Account", "",
JOptionPane.INFORMATION_MESSAGE);
// Accepts user name and password
String un = JOptionPane.showInputDialog("Enter user name: ");
String pa = JOptionPane.showInputDialog("Enter password: ");
// Accepts initial balance
double bal = Double.parseDouble
(JOptionPane.showInputDialog("Enter initial balance$ "));
// Accepts fee
double fee = Double.parseDouble
(JOptionPane.showInputDialog("Enter Fee Charged: "));
// Creates a checking account using parameterized constructor
// Increase the counter by one
ca[caCounter++] = new CheckingAccount(un, pa, bal, fee);
}// End of method
});// End of anonymous class
// Registers action listener to cancelB button using anonymous class
creditB.addActionListener(new ActionListener()
{
// Overrides the actionPerformed() method of ActionListener interface
public void actionPerformed(ActionEvent ae)
{
// Accepts user name and password
String un = JOptionPane.showInputDialog("Enter user name: ");
String pa = JOptionPane.showInputDialog("Enter password: ");
// Checks if current radio button is selected
if(currentR.isSelected())
{
// Calls the method to match the user name and password
// Third parameter 1 for checking account
// Stores the found status in pos
int pos = search(un, pa, 1);
// Checks if pos is -1 record not found
if(pos == -1)
JOptionPane.showMessageDialog(jf,
"No such user name or password found.",
"Invalid", JOptionPane.INFORMATION_MESSAGE);
// Otherwise record found
else
{
// Accepts the deposit amount
double amt = Double.parseDouble(JOptionPane.showInputDialog
("Enter the deposit amount: "));
// Calls the method to deposit for pos index position account
if(ca[pos].credit(amt))
JOptionPane.showMessageDialog(jf,
"Deposit Successful." + "\n Balance $"
+ ca[pos].getBalance(),
"Success", JOptionPane.INFORMATION_MESSAGE);
// Otherwise invalid amount
else
JOptionPane.showMessageDialog(jf,
"Invalid deposit amount.",
"Failure", JOptionPane.INFORMATION_MESSAGE);
}// End of else
}// End of if condition
// Otherwise saving radio button selected
else
{
// Calls the method to match the user name and password
// Third parameter 2 for saving account
// Stores the found status in pos
int pos = search(un, pa, 2);
// Checks if pos is -1 record not found
if(pos == -1)
JOptionPane.showMessageDialog(jf,
"No such user name or password found.",
"Invalid", JOptionPane.INFORMATION_MESSAGE);
// Otherwise record found
else
{
// Accepts the deposit amount
double amt = Double.parseDouble(JOptionPane.showInputDialog
("Enter the deposit amount: "));
// Calls the method to deposit for pos index position account
if(sa[pos].credit(amt))
JOptionPane.showMessageDialog(jf,
"Deposit Successful." + "\n Balance $"
+ sa[pos].getBalance(),
"Success", JOptionPane.INFORMATION_MESSAGE);
// Otherwise invalid amount
else
JOptionPane.showMessageDialog(jf,
"Invalid deposit amount.",
"Failure", JOptionPane.INFORMATION_MESSAGE);
}// End of else
}// End of outer else
}// End of method
});// End of anonymous class
// Registers action listener to cancelB button using anonymous class
debitB.addActionListener(new ActionListener()
{
// Overrides the actionPerformed() method of ActionListener interface
public void actionPerformed(ActionEvent ae)
{
// Accepts user name and password
String un = JOptionPane.showInputDialog("Enter user name: ");
String pa = JOptionPane.showInputDialog("Enter password: ");
// Checks if current radio button is selected
if(currentR.isSelected())
{
// Calls the method to match the user name and password
// Third parameter 1 for checking account
// Stores the found status in pos
int pos = search(un, pa, 1);
// Checks if pos is -1 record not found
if(pos == -1)
JOptionPane.showMessageDialog(jf,
"No such user name or password found.",
"Invalid", JOptionPane.INFORMATION_MESSAGE);
// Otherwise record found
else
{
// Accepts the withdrawal amount
double amt = Double.parseDouble(JOptionPane.showInputDialog
("Enter the withdrawal amount: "));
// Calls the method to withdraw for pos index position account
int val = ca[pos].debit(amt);
// Checks if val is -1 invalid withdraw amount
if(val == -1)
JOptionPane.showMessageDialog(jf,
"Invalid withdrawal amount.",
"Failure", JOptionPane.INFORMATION_MESSAGE);
// Otherwise checks if val is 0 insufficient balance
else if(val == 0)
JOptionPane.showMessageDialog(jf,
"Insufficient fund to withdrawal.",
"Failure", JOptionPane.INFORMATION_MESSAGE);
// Otherwise success
else
JOptionPane.showMessageDialog(jf,
"Successfuly withdrawal amount." + "\n Balance $"
+ ca[pos].getBalance(),
"Success", JOptionPane.INFORMATION_MESSAGE);
}// End of else
}// End of if condition
else
{
// Calls the method to match the user name and password
// Third parameter 2 for saving account
// Stores the found status in pos
int pos = search(un, pa, 2);
// Checks if pos is -1 record not found
if(pos == -1)
JOptionPane.showMessageDialog(jf,
"No such user name or password found.",
"Invalid", JOptionPane.INFORMATION_MESSAGE);
// Otherwise record found
else
{
// Accepts the withdrawal amount
double amt = Double.parseDouble(JOptionPane.showInputDialog
("Enter the withdrawal amount: "));
// Calls the method to withdraw for pos index position account
int val = sa[pos].debit(amt);
// Checks if val is -1 invalid withdraw amount
if(val == -1)
JOptionPane.showMessageDialog(jf,
"Invalid withdrawal amount.",
"Failure", JOptionPane.INFORMATION_MESSAGE);
// Otherwise checks if val is 0 insufficient balance
else if(val == 0)
JOptionPane.showMessageDialog(jf,
"Insufficient fund to withdrawal.",
"Failure", JOptionPane.INFORMATION_MESSAGE);
// Otherwise success
else
JOptionPane.showMessageDialog(jf,
"Successfuly withdrawal amount. \n Balance $"
+ sa[pos].getBalance(),
"Success", JOptionPane.INFORMATION_MESSAGE);
}// End of else
}// End of outer else
}// End of method
});// End of anonymous class
}// End of default constructor
// Method to search a user name and password and returns found index position
// Otherwise returns -1
int search(String un, String pa, int type)
{
// Checks if type is 1 then checking account
if(type == 1)
{
// Loops till number of checking account
for(int c = 0; c < caCounter; c++)
// Checks if current account user name and password is equals
// to the user entered user name and password
if(un.compareTo(ca[c].userName) == 0 &&
un.compareTo(ca[c].password) == 0 )
// Returns the found index position
return c;
// Otherwise return -1 for not found
return -1;
}// End of if condition
// Otherwise it is 2 for saving account
else
{
// Loops till number of saving account
for(int c = 0; c < saCounter; c++)
// Checks if current account user name and password is equals
// to the user entered user name and password
if(un.compareTo(sa[c].userName) == 0 &&
un.compareTo(ca[c].password) == 0 )
// Returns the found index position
return c;
// Otherwise return -1 for not found
return -1;
}// End of else
}// End of method
// main method definition
public static void main(String[] args)
{
// Calls the default constructor of AccountGUI class
new AccountGUI();
}// End of main method
}// End of driver class
Sample Output:

Create an Inheritance hierarchy that a bank may use to represent customer's bank accounts (Checking and...
In C++ Create an inheritance hierarchy that a bank might use to represent customers’ bank accounts. All customers at this bank can deposit (i.e., credit) money into their accounts and withdraw (i.e., debit) money from their accounts. More specific types of accounts also exist. Savings accounts, for instance, earn interest on the money they hold. Checking accounts, on the other hand, charge a fee per transaction (i.e., credit or debit). Create an inheritance hierarchy containing base class Account and derived...
Should be in C#
Create an inheritance hierarchy that a bank might use to
represent customers’ bank accounts. All customers at this back can
deposit (i.e. credit) money into their accounts and withdraw (i.e.
debit) money from their accounts. More specific types of accounts
also exist. Savings accounts, for instance, earn interest on the
money they hold. Checking accounts, on the other hand, charge a fee
per transaction.
Create base class Account and derived classes SavingsAccount and
CheckingAccount that inherit...
Introduction Extend the inheritance hierarchy from the previous project by changing the classes to template classes. Do not worry about rounding in classes that are instantiated as integer classes, you may just use the default rounding. You will add an additional data member, method, and bank account type that inherits SavingsAc-count ("CD", or certicate of deposit). Deliverables A driver program (driver.cpp) An implementation of Account class (account.h) An implementation of SavingsAccount (savingsaccount.h) An implementation of CheckingAccount (checkingaccount.h) An implementation of...
MAIN OBJECTIVE Develop a polymorphic banking program using the Account hierarchy created (below). C++ Capture an output. polymorphism. Write an application that creates a vector of Account pointers to two SavingsAccount and two CheckingAccountobjects. For each Account in the vector, allow the user to specify an amount of money to withdraw from the Account using member function debit and an amount of money to deposit into the Account using member function credit. As you process each Account, determine its...
For this week's assignment , please create an application following directions in the attached document.(windows form application) Create a base class named Account and derived classes named SavingsAccount and CheckingAccount that inherit from class Account. Base class Account should include one private instance variable of type decimal to represent the account balance. The class should provide a constructor that receives an initial balance and uses it to initialize the instance variable with a public property. The property should validate the...
Please show it in C++. Thank you!
Problem Definition Create an inheritance hierarchy containing base class Account and derived class Savings-Account. Base class Account should include one data member of type double to represent the account balance. The class should provide a constructor that receives an initial baiance and uses it to initialize the data member. The class should provide three member functions. Member function credit should add an amount to the current balance. Member function debit should withdraw money...
I am trying to create a ATM style bank program that accept the customer id , in the welcoming panel ,but how do i make when the customer input their id# and click on the ok button then they have 3 or so tries to input the correct id# and if successful then send to the other panel where they choose which transaction to they want to make for example savings , checking account , make and deposit , and...
: Implement the following given scenario in C++ a. Create an inheritance hierarchy by writing the source code, containing base class BankAccount and derived classes SavingsAccount and CheckingAccount that inherit from class BankAccount. b. Implement Polymorphism where required to achieve the polymorphic behavior. c. Multiple constructors be defined for initializing the account of a user. d. The class should provide four member functions. i. Member function Credit should add an amount to the current balance. ii. Member function Debit should...
Now create another class named SavingsAccount. This should be a subclass of BankAccount. A SavingsAccount should have an interest rate that is specified in its constructor. Furthermore, there should be a method, addInterest, that deposits interest into account, based on the account balance and interest rate. Create another subclass of BankAccount named CheckingAccount. A CheckingAccount should keep track of the number of transactions made (deposits and withdrawals). Name this field transactionCount. Also, the set fee for transactions is three dollars,...
Bank Accounts Look at the Account class Account.java and write a main method in a different class to briefly experiment with some instances of the Account class. • Using the Account class as a base class, write two derived classes called SavingsAccount and CheckingAccount. A SavingsAccount object, in addition to the attributes of an Account object, should have an interest variable and a method which adds interest to the account. A CheckingAccount object, in addition to the attributes of an...