Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Date:2014.10.08
- * @author LinChuWen
- * NCHU EE,course number:2335
- * course name:Object Oriented Language
- *
- * Textbook:Big Java: Late Objects - Cay S. Horstmann
- * Problem:P3.27
- */
- import java.util.Scanner;
- public class HW2_P3_27 {
- public static void main(String[] args) {
- int month;
- Scanner input = new Scanner(System.in);
- try{
- System.out.print("Please enter a month: ");
- month = input.nextInt();
- switch(month){
- case 1:
- case 3:
- case 5:
- case 7:
- case 8:
- case 10:
- case 12:
- System.out.println("31 days");
- break;
- case 4:
- case 6:
- case 9:
- case 11:
- System.out.println("30 days");
- break;
- case 2:
- System.out.println("28 or 29 days");
- break;
- } //switch end
- } //try end
- catch(Exception ex){
- System.out.println("Wrong Input!");
- } //catch end
- finally{
- input.close();
- } //finally end
- } //main end
- } //class end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement