Answer to Question #248942 in Java | JSP | JSF for Locos

Question #248942

Develop an application in Java for automating the Banking Operations using interfaces.

Create an interface called “Transaction” which contains the functions such as deposit,

withdraw, and viewBalance. Create another interface called “Displayable” which

contains the Display () function to display the account details.

Create an abstract class called “Account” with bank account details such as acc_name,

acc_no, and balance. Add necessary constructors.

Create a “Bank” class which implements the “Transaction”, “Displayable” interfaces

and inherits “Account” class.

Perform menu driven operations like Deposit, Withdraw and Balance Enquiry, View

Account Details from a Main class. Write logics in the corresponding methods.


1
Expert's answer
2021-10-10T01:48:25-0400
import java.util.Scanner;
interface Transaction{ 
    void deposit();
    void withdraw(); 
    void viewBalance(); 
}  
interface Displayable{  
    void Display(); 
}  




abstract class Account{ 
    public String acc_name;
    public int acc_no; 
    public double balance;
    public Account(double b){
        balance=b;
    }
}
public class Main{ 
    public static void main(String args[]){  
        Bank b=new Bank(500.00);
        b.deposit();
        b.withdraw();
        b.viewBalance();
     }  
} 




class Bank extends Account implements Transaction, Displayable {
    public Bank(double b){
        super(b);
    }
    public void deposit(){
        double amount;
        System.out.println("Enter amount to deposit: ");
        Scanner in=new Scanner(System.in);
        amount=in.nextDouble();
        balance=balance+amount;
        System.out.println("You have deposited "+amount+".Your current balance is: "+balance);
    }
    public void withdraw(){
        double amount;
        System.out.println("Enter amount to withdraw: ");
        Scanner in=new Scanner(System.in);
        amount=in.nextDouble();
        balance=balance-amount;
        System.out.println("You have withdrawn "+amount+".Your current balance is: "+balance);
    }
    public void viewBalance(){
        System.out.println("Your account balance is: "+balance);
    }
    public void Display(){
        
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS