vendredi 29 août 2014

Output keeps on running


Vote count:

0




Why the output keeps on running?when i run this program, and i enter the in the output, it keeps running, and doesnt let me allow to enter any more number. why is it happening?


import java.util.InputMismatchException; import java.util.Scanner;


public class ExceptionTest2 {



public static void main(String[] args) {
Scanner st = new Scanner(System.in);
int ab,bd,cde;
ab=bd=cde=0;
boolean infinite,in;

do {
System.out.println("Enter the numbers to divide");
infinite=false;
in=true;
try { ab = st.nextInt();
bd = st.nextInt();
infinite=false;
in=true;
} catch (InputMismatchException e) {
System.out.println("Invalid input");
in=true;
} finally {
if (in) {
try {

System.out.println("I am in try block before exception");

cde = ab/bd;
System.out.println("I am in try block after exception");
} catch (Exception e) {

infinite=true;
} finally {

if(!infinite) System.out.println("Answer is " + cde);;
}
}

}


} while (cde!=100);
st.close();
}


}



asked 22 secs ago







Output keeps on running

Aucun commentaire:

Enregistrer un commentaire