I. Practice with the use of switch statements
Exercise 1
The final result shows that there is no problem.
The internal of the switch statement was interrupted, and in the compilation operation, the running flow of switch was explored, and the result was as follows:
Exercise 2
Exercise 3
Multiple answer statements, corresponding to the same content.
Note: The variable is assigned a value of 3, enter the switch statement, then case 3 and the variable match, but case 3 no content, no break, can only go down to run, and do not need to judge, directly run Case 4 output statement, and then encounter case 4 of the break exit switch statement. If the variable is assigned a value of 4, enter the switch statement, Case 3 does not match, regardless of whether case 3 has content, the next case is directly matched judgment.
→ Multiple answer identification, corresponding to an answer content.
I have re-written the "Week" and "season" exercises.
Summarize:
The idea of programming is still not available, very passive, not in-depth thinking of the meaning behind the knowledge points that are usually learned.
The essence of the demand for the week and the season is: the user enters the data, then the program determines, and outputs the corresponding data.
If and switch are too similar, although one is to judge the structure, one is to choose the structure, but essentially the same.
The writing form is divided into two types, which are more input data and less input data.
Java-preliminary Understanding-Chapter III-statement-switch exercises