04-01 Java switch, for, while, do while statements, loop nesting, jump statements break, continue, return
sentence
Switch statement format:
Switch statement format:
Precautions for switch statement:
根据你键盘录入的字符串,判断是否有满足要求的,如果有就输出。
What is the difference between an IF statement and a switch statement?
For loop statement
For loop statement format:
Output all daffodils on the console:
while Loop
Basic format of while loop:
What is the difference between a while loop and a for loop?
How many times can the paper with a thickness of 0.01M be folded to ensure that the thickness is not lower than the 8848m height of Mount Everest?
do... while
do... While statement format:
For, while, do Differences between while statements
Pay attention to the dead cycle
Output the 99 multiplication table on the console:
Break, continue, return statements
Break: Break:
Continue: continue:
Return statement:
Execution result: none of the statements after return will be executed.
example:
Demand: Xiaofang's mother gives her 2.5 yuan every day, and she will save it. However, whenever this day is the fifth day or a multiple of 5, she will spend 6 yuan. Excuse me, how many days will Xiaofang save 100 yuan.
Execution results: