Exception Handling In java

Posted on
Exception Dealing with In java

import java.io.*;

import java.util.*;

class myex extends Exception

{

myex(String m)

{

tremendous(m);

}

}

class myex1 extends Exception

{

myex1(String m)

{

tremendous(m);

}

}

public class Financial institution

{

static Scanner enter=new Scanner(System.in);

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

int bal;

static int accno;

String identify;

Financial institution()

{

bal=0;

accno=2873;

identify=””;

}

void newacc()

{

attempt

{

System.out.println(“n Enter Title:: “);

identify=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=enter.nextInt();

if(accno<0) { throw new myex(“naccount no is wrongn”); } System.out.println(“n Your identify is:: ” + identify); } void wd() throws myex1,myex {

System.out.println(“n Enter Acc No:: “);

accno=enter.nextInt();

if(accno<0) { throw new myex(“naccount no is wrongn”); } System.out.println(“n Enter Cash:: “); int cash=enter.nextInt(); if(cash%100!=0) { throw new myex1(“nmoney sd be a number of of 100 n”); } System.out.println(“n Your identify is:: ” + identify); } public static void important (String[] args)

{

int ch;

Financial institution b =new  Financial institution();

do

{

System.out.println(“n 1.New Acc”);

System.out.println(“n 2.Acc Information”);

System.out.println(“n 3.Dep”);

System.out.println(“n 4.Wd”);

System.out.println(“n Enter Ur Selection”);

ch=enter.nextInt();

change(ch)

{

case 1:

b.newacc();

break;

case 2:

attempt

{

b.showinfo();

}catch(Exception e)

{

System.out.println(e.getMessage());

}

break;

case 3:

attempt

{

b.wd();

}

catch(Exception e)

{

System.out.println(e.getMessage());

}

break;

}

}whereas(ch!=5);

}

}

Supply projectgeek.com