Some Selection Problems
Home - About Us
 

Questions

Write a Java application to solve each of the following questions.
  1. Ask the user how many days are in the month of Janary. Answer "Correct!" for 31, and "Incorrect..." for all other answers. Sample run (the text generated by the computer is shown in plain text and the text entered by the computer in bold for illustrative purposes -- your program will run with all text as plain text):
    	  How many days in January? 30
    	  Incorrect!
    
  2. Generate and report a single integer in the range of 1 to 10.  Report whether or not it is an odd or even number.  Sample run:
    	  Random number: 3 (odd)
    Every time you run the program it will generate a different random number.
     
  3. Ask the user to enter the numeric value for a day of the week (where '1' is Sunday, '2' is Monday, etc.).  Report whether that day is a weekday or if it falls on a weekend.  If an invalid number is entered, such as a '0' or a '9', then report "That is not a valid day". 

    Here is a sample run of the program:
    	  Enter a day of the week (1 to 7): 3
    	  That is a weekday.
    Here is another run of the program:
    	  Enter a day of the week (1 to 7): 7
    	  That is a weekend.
    And another run of the program:
    	  Enter a day of the week (1 to 7): 9
    	  That is not a valid day.
  4. Enter a code to indicate your college standing (1 = freshman, 2 = sophomore, 3 = junior, 4 = senior). Report the appropriate year (or "Invalid code for values other than 1 to 4).

    Sample run:
    	  What is your year at college? : 3
    	  Your are a junior.
Home - About Us
Copyright © 2006 by Kiowok, Ann Arbor, Michigan, USA