title: end java program when input 'q'
body: <p>i want to end my java program if i input q or Q. 
  otherwise, the program will continue running, printing the question and asking for input.
  will this work?</p>
  
  <pre><code>Scanner sc = new Scanner(System.in);
  while(sc.hasNext())
  {
  System.out.print("Enter departure city &lt;'Q' or 'q' to exit&gt;: ");
  String input = sc.next();
  
  if(!(input.equals('q')) || !(input.equals('Q'))){
  //system continues
  }
  else{
  System.exit(0);
  }
  }
  </code></pre>