title: Looping for odd and even number in java
body: <p>how do i  repeatedly ask the user to enter an input until the user enters a negative number. If the user enters a negative number or 0, the program will end?</p>
  
  <pre><code>import java.util.Scanner;
  public class OddEvenInt {
  
      public static void main(String args[]) {
  
          Scanner s = new Scanner(System. in );
          int x;
  
          do {
              System.out.println("Enter an integer to check if it is odd or even ");
              x = s.nextInt();
  
              if (x % 2 == 0)
                  System.out.println("You entered an even number.");
              else
                  System.out.println("You entered an odd number.");
          } while (x % 2 == 0);
      }
  }
  </code></pre>