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
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);
}
}
Comments
Leave a comment