All pastes #929957 Raw Edit

Miscellany

public text v1 · immutable
·published 2008-03-06 04:42 UTC
rendered paste body
import java.util.*;

public class Hogwarts
{
   public static void main(String[] args)
   {

      final int MIN_AGE = 10;
      final int MAX_AGE = 12;

      String stud;
      int age = 0;
      char letter;
      Scanner scan = new Scanner(System.in);

      while(scan.hasNext())
      {
         stud = scan.next();
         age = scan.nextInt();

//THIS IS THE AREA OF PROBLEM *************************************
if ( !isdigit(age) )
{
System.out.println("wee");
}
      else
      {
         System.out.println("Age is not an integer; terminate the program.");
         System.exit(0);
      }
//END AREA OF PROBLEM       *************************************
         System.out.println("Student:   "+stud);
         System.out.println("Age:       "+age);
         letter = stud.charAt(0);
         if((age>=MIN_AGE)&&(age<=MAX_AGE))
         {
            if(letter == 'R')
            {
            System.out.println("Ravenclaw");
            System.out.println();
            }
            else if(letter == 'G')
            {
            System.out.println("Gryffindor");
            System.out.println();
            }
            else if(letter == 'H')
            {
            System.out.println("Hufflepuff");
            System.out.println();
            }
            else
            {
            System.out.println("Slytherin");
            System.out.println();
            }
        }
        else
        {
            System.out.println("Age isn't in the valid age group, terminate the program.");
            System.exit(0);
        }

      } // End While loop
   } // End of Main
} // End of Hogwarts