import java.util.*;
class myex extends Exception
{
myex(String m)
{
super(m);
}
}
class myex1 extends Exception
{
myex1(String m)
{
super(m);
}
}
public class Bank
{
static Scanner input=new Scanner(System.in);
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int bal;
static int accno;
String name;
Bank()
{
bal=0;
accno=2873;
name=””;
}
void newacc()
{
try
{
System.out.println(“\n Enter Name:: “);
name=br.readLine();
accno++;
System.out.println(“\n Your Acc No:: “+accno);
}
catch(Exception e){}
}
void showinfo() throws myex
{
System.out.println(“\n Enter Acc No:: “);
accno=input.nextInt();
if(accno<0)
{
throw new myex(“\naccount no is wrong\n”);
}
System.out.println(“\n Your name is:: ” + name);
}
void wd() throws myex1,myex
{
System.out.println(“\n Enter Acc No:: “);
accno=input.nextInt();
if(accno<0)
{
throw new myex(“\naccount no is wrong\n”);
}
System.out.println(“\n Enter Money:: “);
int money=input.nextInt();
if(money%100!=0)
{
throw new myex1(“\nmoney sd be multiple of 100 \n”);
}
System.out.println(“\n Your name is:: ” + name);
}
public static void main (String[] args)
{
int ch;
Bank b =new Bank();
do
{
System.out.println(“\n 1.New Acc”);
System.out.println(“\n 2.Acc Info”);
System.out.println(“\n 3.Dep”);
System.out.println(“\n 4.Wd”);
System.out.println(“\n Enter Ur Choice”);
ch=input.nextInt();
switch(ch)
{
case 1:
b.newacc();
break;
case 2:
try
{
b.showinfo();
}catch(Exception e)
{
System.out.println(e.getMessage());
}
break;
case 3:
try
{
b.wd();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
break;
}
}while(ch!=5);
}
}
Leave a Reply