18 Apr, 2022
import java.util.Scanner;
public class Bank {
private int balance=10000;
private int pwd;
public void Deposite(int money)
{
System.out.println("Enter Your Password Please ");
Scanner P=new Scanner(System.in);
pwd = P.nextInt();
if(pwd==567)
{
balance=balance+money;
System.out.println("Deposite Money "+money);
System.out.println("Total Money "+balance);
}
else
{
System.out.println("Wrong Password");
}
}
public void Withdraw(int money)
{
System.out.println("Enter Your Password Please ");
Scanner P=new Scanner(System.in);
pwd = P.nextInt();
if(pwd==567)
{
balance=balance-money;
System.out.println("Withdraw Money "+money);
System.out.println("Total Money "+balance);
}
else
{
System.out.println("Wrong Password");
}
}
public void Chackbalance()
{
System.out.println("Enter Your Password Please ");
Scanner P=new Scanner(System.in);
pwd = P.nextInt();
if(pwd==567)
{
System.out.println("Total Money "+balance);
}
else
{
System.out.println("Wrong Password");
}
}
}
class customer1 {
public static void main(String[] args)
{
Bank b= new Bank();
int num,num2;
System.out.println("Enter Your Choice ");
System.out.println("1. Deposite");
System.out.println("2.Withdraw");
System.out.println("3. Chack Balance");
Scanner S2=new Scanner(System.in);
num=S2.nextInt();
switch(num)
{
case 1:
System.out.println("Enter Your Deposite amount ");
Scanner S3=new Scanner(System.in);
num2=S3.nextInt();
b.Deposite(num2);
break;
case 2:
System.out.println("Enter Your Withdraw amount ");
Scanner S4=new Scanner(System.in);
num2=S4.nextInt();
b.Withdraw(num2);
break;
case 3: b.Chackbalance();
break;
default:
System.out.println("Wrong choice ");
}
}
}