
// This program takes in a month (integer from 1 to 12) 
// and returns the number of days in that month.
// Algorithm: (input, process, output)

public class NumberOfDays
{
  public static void main(String args[])
  {
      // Declare variables here
      int month;      // desired month, from 1 to 12
      int numDays = 0; // final output: number of days in month
	
      // Prompt the user to input a month number.
      System.out.println("This program calculates the number of days " +
			 "in a given month.");
      System.out.println("Which month would you like? " +
			 "(specify by number, 1-12)");
      month = SavitchIn.readInt();

      // Sanity check!  Check that the input value is valid (from 1-12).  
      // Loop until it is.
      // (user can also hit ctrl-c to break out of the program).
      while ((month < 1) || (month > 12))
      {
	  System.out.println("Invalid month. " +
			     "Please enter a number from 1 to 12.");
	  month = SavitchIn.readInt();
      }	

      // Your implementation of your algorithm starts here.


      // Display the result to the user.
      System.out.println("There are " + numDays + " days in month " + month);

  }
}
