Please use NETBEANS or JAVA ECLIPSE WITH GUI Bank Account. Write a program to ma
ID: 639715 • Letter: P
Question
Please use NETBEANS or JAVA ECLIPSE WITH GUI
Bank Account. Write a program to maintain a person's savings and checking accounts. The program should keep track of and display the balances in both accounts, and maintain a list of transactions(deposits, withdrawals, fund transfers, and check clearings) separately for each account. The two lists of transactions should be stored in text files.
Consider the form below. The two drop down combo boxes should each contain the items Checkings and Savings. Each of the four group boxes corresponds to a type of transaction. (When Savings is selected in the Account combo box, the Check group box should disappear.) The user makes a transaction by entering data into the text boxes of a group box and pressing the associated button. The items appearing in the DataGridView control should correspond to the type of account that has been selected. The caption of the second label in the Transfer group box should toggle between "to Checking" and "to Savings" depending on the item selected in the "Transfer from" combo box. If a transaction cannot be carried out, a message (such as "Insufficient funds") should be displayed. Two text file should be maintained (one for each type of account) and should be updated each time a transaction is carried out.
The program should use two classes, Transaction and Account. The class Transaction should have properties for transaction name, amount, date, and whether it is a credit (deposit) or debit (withdrawal/check).
The class Account, which will have both a checking account and a savings account as instances, should use an array of Transaction objects. In addition, it should have properties for name (Checking or Savings) and balance. It should have methods to carry out a transaction (if possible) and to load the set of transactions from a text file. The events InsufficientFunds and TransactionCommitted should be raised at appropriate times.
Explanation / Answer
i done without gui...hope t helps for applying gui to these files
Superclass: BankAccount
Subclass: Checking Account
Subclass: Savings Account
Method class: BankApp
BankAccount Superclass:
public class BankAccount {
String firstName;
String lastName;
String ssn;
protected float balance;
float withdraw;
float deposit;
long accountNumber;
BankAccount (){
}
BankAccount(String firstName, String lastName, String ssn, float balance){
this.firstName = firstName;
this.lastName = lastName;
this.ssn = ssn;
this.balance = balance;
}
long accountNumber() {
long accountNumber = (long) Math.floor(Math.random() * 9000000000L) + 1000000000L;
return accountNumber;
}
public void deposit(float amount) {
balance = balance + amount;
System.out.println(firstName + " " + lastName + " deposited $" + deposit + ". Current Balance $" + balance);
}
public void withdraw(float amount) {
if (balance >= amount) {
balance = balance - amount;
System.out.println(firstName + " " + lastName + " withdrew $" + amount + ". Current Balance $" + balance);
}
if (balance < amount) {
System.out.println("Unable to withdraw " + amount + " for " + firstName + " " + lastName + " due to insufficient funds.");
}
}
}
Checking Account Subclass:
public class CheckingAccount extends BankAccount {
float amtInterest;
float applyInterest;
String displayBalance;
public CheckingAccount() {
}
public CheckingAccount(String firstName, String lastName, String ssn, float balance) {
super(firstName, lastName, ssn, balance);
System.out.println("Successfully created account for " + firstName + " " + lastName + " " + accountNumber);
System.out.println(firstName + " " + lastName + ", Balance $" + balance);
}
float applyInterest () {
if (balance <= 10000) {
balance = balance * 0.1f;
}
if (balance > 10000) {
balance = 1000 + (balance * 0.02f);
}
return balance;
}
float displayBalance() {
return balance;
}
}
I
Output:
Successfully created account for Alin Parker 0 //Not displaying a random account number (1)
Alin Parker, Balance $1000.0
Successfully created account for Mary Jones 0
Mary Jones, Balance $500.0
Successfully created account for John Smith 0
John Smith, Balance $200.0
Alin Parker deposited $0.0. Current Balance $23000.0 //Deposit being calculated but displayed as 0 (2)
Mary Jones deposited $0.0. Current Balance $12500.0
Alin Parker withdrew $0.0. Current Balance $21000.0 //Withdrawal being calculated but displayed as 0 (3)
Mary Jones withdrew $0.0. Current Balance $11500.0
Alin Parker withdrew $0.0. Current Balance $-28580.0 //Should not show negative balance and only notice below (4)
Unable to withdraw 30000.0 for Alin Parker due to insufficient funds
public class BankApp {
public static void main(String[] args) {
CheckingAccount acct1 = new CheckingAccount("Alin", "Parker", "123-45-6789", 1000.0f);
CheckingAccount acct2 = new CheckingAccount("Mary", "Jones", "987-65-4321", 500.0f);
SavingsAccount acct3 = new SavingsAccount("John", "Smith", "1233-45-6789", 200.0f);
acct1.deposit(22000.00f);
acct2.deposit(12000.00f);
acct1.withdraw(2000.00f);
acct2.withdraw(1000.00f);
acct1.applyInterest(); //seems to skip
acct2.applyInterest(); //seems to skip
acct1.displayBalance(); //seems to skip
acct2.displayBalance(); //seems to skip
acct1.withdraw(30000.00f);
}
}