in jave please: modify the CheckingAccount class, to become a simple derived cla
ID: 3761644 • Letter: I
Question
in jave please: modify the CheckingAccount class, to become a simple derived class of the parent class Account. The Account class contains the instance variables String name(the name of the person who owns the account) and double balance( the current balance of the account). There should be appropriate get methods in Account class to get the name and balance fields. The account name should appear in all reports and dialogue. The CheckingAccount class will still have the instance variables double totalServiceCharges, and Transaction[ ] transList (orArrayList transList). Also, create a Check class, a simple derived class of the Transaction class. The Check class will include the check number for each check transaction. The check number will be prompted for as the check is entered, and displayed in the checks listing. Also, create a Deposit class, a simple derived class of the Transaction class. The Deposit class will include the cash amountand check amount that total to the transaction amount. The cash and check amount for each deposit will be input in a new Deposit input screen. (see sample run below) In this application’s design, you should have the following classes: 1. The Main class ( create the frame, add the panel and set it visible) . This program is event-driven. You cannot put all the processing steps/logic in main method. You can put them in helper methods in the Main class, however. 2. The CheckOptionsPanel class(create the GUI components, add listeners, add to Panel) This is the class where most of the action(driven by events) takes place.You might want to put the processing methods (to be called by the listeners) in this class, along with the declaration of the CheckingAccount instance that you are processing. 3. The CheckingAccount class to define the CheckingAccount object.(please keep this class methods simple. This is the file cabinet object which will be written to a file in a later assignment) 4. The Account class which serves as a Parent to the CheckingAccount class. 5. The Transaction class to define the transactions stored in the array inside the CheckingAccount objects, and parent of the Check class. 6. The Check class to define the check number and get method for processing the check number for each check transaction. 7. The Deposit class to define the cash and check amounts that comprise the total deposit transaction amount.
Explanation / Answer
import javax.swing.*;
import java.text.NumberFormat;
import javax.swing.JOptionPane;
public class Application {
public static void main(String[] args) {
boolean dn = false;
String str11;
NumberFormat format1 = NumberFormat.getCurrencyInstance();
String option11 = JOptionPane.showInputDialog("Enter an account type (checking or savings):");
if(option11.equalsIgnoreCase("checking")){
String accountname = JOptionPane.showInputDialog("Enter a account name:");
CheckingAccount cAccount11 = new CheckingAccount(accountname, 0.0);
while(!dn){
str11 = JOptionPane.showInputDialog("Enter the transaction (deposit or withdraw):");
if(str11.equalsIgnoreCase("deposit")){
str11 = JOptionPane.showInputDialog("Enter an amount to deposit:");
double m11= Double.parseDouble(str11);
cAccount11.deposit(m11);
}
else if (str11.equalsIgnoreCase("withdraw")){
str11 = JOptionPane.showInputDialog("Enter an amount to withdraw:");
double n11 = Double.parseDouble(str11);
cAccount11.withdraw(n11);
}
str11 = JOptionPane.showInputDialog("Enter a choice (quit or not):");
if(str11.equalsIgnoreCase("quit")){
System.out.println("The Checking account information for " + cAccount11.accountname);
System.out.println(cAccount11);
dn = true;
}
}
}
else if(option11.equalsIgnoreCase("savings")){
String accountname = JOptionPane.showInputDialog("Enter the account name:");
SavingsAccount sAccount11 = new SavingsAccount(accountname, 0.0);
while(!dn){
str11 = JOptionPane.showInputDialog("Enter the transaction (deposit or withdraw):");
if(str11.equalsIgnoreCase("deposit")){
str11 = JOptionPane.showInputDialog("Enter an amount to deposit:");
double m11 = Double.parseDouble(str11);
sAccount11.deposit(m11);
}
else if (str11.equalsIgnoreCase("withdraw")){
str11 = JOptionPane.showInputDialog("Enter the amount to withdraw:");
double n11 = Double.parseDouble(str11);
sAccount11.withdraw(n11);
}
str11 = JOptionPane.showInputDialog("Enter the choice (quit or not):");
if(str11.equalsIgnoreCase("quit")){
System.out.println("The Savings account information for " + sAccount11.accountname);
System.out.println("The Balance before interest and tax: " + sAccount11.balance);
System.out.println("The Interest earned: " + format1.format(sAccount11.interestAmount()));
System.out.println("The Tax paid: " + format1.format(sAccount11.taxAmount()));
System.out.println(sAccount11);
dn = true;
}
}
}
else {
System.out.println("The Wrong input, system exits.");
}
}
}
public abstract class Account {
protected String accountname;
protected double accountbalance;
public void depositamount(double m){
accountbalance += m;
}
public double withdrawamount(double n){
accountbalance -= n;
return accountbalance;
}
public abstract double getaccountBalance();
public String toString() {
return "Name: " + accountname + " Balance: " + accountbalance;
}
}
public class CheckingAccount {
public CheckingAccount(){
}
public void getaccountBalance(){
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.