In: Computer Science
import java.io.*;
import java.util.*;
class Account{
static long balance=0;
}
class Bankaccount extends Account {
Scanner sc=new Scanner(System.in);
void Showbalance(){
System.out.println(balance);
}
void deposit()
{
long amt;
System.out.println("Enter Amount U Want to Deposit : ");
amt=sc.nextLong();
balance=balance+amt;
}
void withdrawal()
{
long amount;
System.out.println("Enter Amount U Want to withdraw : ");
amount=sc.nextLong();
if(balance>=amount)
{
balance=balance-amount;
}
else
{
System.out.println("Less Balance..Transaction Failed..");
}
}
}
class Main
{
public static void main(String arg[])
{
Scanner sc=new Scanner(System.in);
Bankaccount b = new Bankaccount();
int ch;
do
{
System.out.println("Main Menu\n1.Balance\n2.Deposit\n3.Withdrawal\n4.Exit");
ch=sc.nextInt();
switch(ch)
{
case 1:
b.Showbalance();
break;
case 2:
b.deposit();
break;
case 3:
b.withdrawal();
break;
case 4:
System.out.println("Good Bye..");
break;
}
}
while(ch!=4);
}
}