Answer to Question #270328 in Java | JSP | JSF for HONOUR

Question #270328

create a banking console java application

Implement the following java concept in your solution and highlight in your documentation or code where you did it: and explain the steps

1. Class and Object

2. File and Stream

3. Exception Handling


1
Expert's answer
2021-11-24T00:41:45-0500
class Banking {
    int tot = 90;
    void withdraw(String n, int Wit)
    {
        if (tot >= Wit) {
            System.out.println(n + " withdrawn "
                               + Wit);
 
            tot = tot - Wit;
            System.out.println("Balance after withdrawal: "
                               + tot);
            try {
                Thread.sleep(1000);
            }
            catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        else {
            System.out.println(n
                               + " Insufficient fund to witdraw"
                               + Wit);
 
            System.out.println("Your balance is: " + tot);
            try {
                Thread.sleep(1000);
            }
 
            catch (InterruptedException e) {
 
                e.printStackTrace();
            }
        }
    }
    void deposit(String n, int deposit)
    {
        System.out.println(n + " Deposited " + deposit);
        tot = tot + deposit;
        System.out.println("Balance after deposit: "
                           + tot);
            Thread.sleep(1000);
        }
        catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
class Main {
    public static void main(String[] args)
    {
        Banking B = new Banking();
        B.withdraw("June", 10);
        B.withdraw("Aneb", 30);
        B.deposit("Chris", 45);
        B.withdraw("Bob", 70);
        B.withdraw("Ruth", 50);
    }
}

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