/* 9/23/2019
 
 */
import java.util.Scanner;

/** want to make sure that the user enters a valid number
  */
public class ValidateInput {
  /** read in ONE number and verify it */
  public static void main(String[] args) { 

      Scanner scanner = new Scanner(System.in);
      System.out.println("Enter a number between 5 and 10 (inclusive): ");
      int num=scanner.nextInt();
      // using a while loop to validate input
      while (num<5 || num>10){
         System.out.println("you entered an invalid number: " + num +
                            "\nPlease enter a number between 5 and 10 (inclusive): ");
         num=scanner.nextInt();
      }
      System.out.println("you entered: " + num);
      
      // say you only want to take in ints
      System.out.println("Enter an integer: ");
      while(!scanner.hasNextInt()) {
          scanner.nextLine(); // read whole line and skip it
          System.out.println("Skipping line, enter an integer: ");
      }
      num=scanner.nextInt();
      System.out.println("you entered: " + num);
      scanner.close();
  }
}

/*** Lab 7:  use a while to implement the following:
  * read in a set of integers, and then print their sum */



