Java-preliminary Understanding-Chapter III-statement-switch exercises

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.