📄 chapter4n1c.java
字号:
/* * program to demonstrate a simple "switch" statement */import java.lancs.* ;public class Chapter4n1c { // constants for the names of the month public static final int JAN = 1 ; public static final int FEB = 2 ; public static final int MAR = 3 ; public static final int APR = 4 ; public static final int MAY = 5 ; public static final int JUN = 6 ; public static final int JUL = 7 ; public static final int AUG = 8 ; public static final int SEP = 9 ; public static final int OCT = 10 ; public static final int NOV = 11 ; public static final int DEC = 12 ; /* * main */ public static void main(String[] args) throws Exception { // read in value for the month BasicIo.prompt("please type in a month (1 to 12) ") ; int month = BasicIo.readInteger() ; // output some information about the month int days = 0 ; switch (month) { case SEP : case APR : case JUN : case NOV : days = 30 ; break ; case FEB : // assume not a leap year, for the present days = 28 ; break ; case JAN : case MAR : case MAY : case JUL : case AUG : case OCT : case DEC : days = 31 ; break ; default : System.out.print("illegal month!") ; } ; System.out.println("Month " + month + " has " + days + " days") ; } // end of method main } // end of class Chapter4n1c
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -