class Product
{
public static void main( String args[])throws IOException
{
System.out.println(" This program checks the product of two numbers.");
System.out.println(" enter first number");
InputStreamReader I = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(I);
String s;
s= br.readLine();
int a= Integer.parseInt(s);
System.out.println(" enter second number");
s= br.readLine();
int b= Integer.parseInt(s);
int res=a*b;
System.out.println(" what is the product of " +a+ " and " +b+ "?");
s= br.readLine();
while(s!= "quit" || s!= "QUIT")
{
int p= Integer.parseInt(s);
if(p==res)
System.out.println(" Correct!");
break;
else
System.out.println(" NO! try again...");
}
System.out.println(" Product of " + a + " and " + b +" is " + res);
}
}
the error is, i want my code to exit from the do loop after if is satisfied. and also, antering quit throws exceptions. cant understand.

New Topic/Question
Reply



MultiQuote




|