Hi,
This is a program to ask the user to type any text and incase he has to exit out of the program, he simply has to type 'q' or 'Q'.
import java.io.*;
class readline
{
public static void main(String args[]) throws IOException
{
char c;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter any text and type \"q\" or \"Q\" to exit") ;
do
{
c=(char)br.read();
}while((c!='Q') || (c!='q'));
}
}
The output is such that the program never exits unless I force a Control + C. Im not able to find the error in the logic.
This is a program to ask the user to type any text and incase he has to exit out of the program, he simply has to type 'q' or 'Q'.
import java.io.*;
class readline
{
public static void main(String args[]) throws IOException
{
char c;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter any text and type \"q\" or \"Q\" to exit") ;
do
{
c=(char)br.read();
}while((c!='Q') || (c!='q'));
}
}
The output is such that the program never exits unless I force a Control + C. Im not able to find the error in the logic.