1. Each of the following questions asks you to collect some type of data or provide some type of operation to the user. For each question, select the most appropriate widget to use. You should select each answer from the following list of widgets:

    1. ________________ You want the user to enter a credit card number

    2. ________________ You want the user to select a university status from the choices of Professor, Student, Administrator, and Secretary. A user is allowed to selecct multiple status's.

    3. ________________ You want the user to select an FM radio station in an internet radio application.

    4. ________________ You want the user to select their county of residence in Tennessee

    5. ________________ You want the user to enter the volume of a speaker that should ranger between 0 and 20.

  2. This problem is meant to give you practice with exception handling. Write a program that reads input from stdin using the Scanner class. Each token should be an integer and the goal of the program is to 1) type check each token, 2) count the number of total tokens and the number of integers, and 3) compute the sum of the integers. Once the program has processed all the input it should print the number of integers, the number of tokens, and the sum of the integers. Each time your program encounters an invalid token it should print out the message "invalid token:" and the value of the token.

    I want your program to catch two exceptions that are generated by the Scanner class's nextInt method:

    1. The InputMismatchException which is thrown if the next token is not an integer.

    2. The NoSuchElementException which is thrown if the input is exhausted.

    I also want you to make use of the finally clause to count the total number of tokens. Because I want you to keep calling nextInt until the input is exhausted you may overcount the number of tokens by 1, in which case you will need to subtract 1 from the total number of tokens at the end of your program. If you want to check the output of your program you can run my sample executable:

    java -cp .:..:/home/cs365/www-home/hw/hw5 myException
    

  3. Write a Java Swing application that displays a slider, two buttons, an increment button and a decrement button, and a label that represents the value of the slider. The increment and decrement buttons should increment and decrement the value of the slider by 1. The program should take three integers as command line arguments:

    1. minValue: The minimum value of the slider
    2. maxValue: The maximum value of the slider
    3. startValue: The starting value of the slider

    The program should use the Integer class's parseInt method to convert the command line arguments to integers and it should use a try/catch block to catch a NumberFormatException if any of the three arguments cannot be converted to an integer.

    The application should place the increment button in the west region of the display, the slider in the center region, the decrement button in the east region, and the value label in the north region. If the user presses the increment button and the value is already at the maximum allowable value for the slider then the application should pop up a message dialog indicating that the value cannot be further incremented. A similar message should be displayed if the user attempts to decrement the value when it is already at its minimum value.

    If you have questions about how your interface should look or behave, you can use the following commands to copy my SliderApp class files to your home file system and then run it:

    cp /home/cs365/www-home/hw/hw5/*.class .
    java SliderApp minValue maxValue startValue