Vi.. Branches:
A
if (an expression)
{
}
Description
1. The expression is the expression used to return the bool shape.
Don't add a semicolon after the 2.if parenthesis
Two
if (an expression)
{
}
Else
{
}
Cases:
1. Enter age, greater than or equal to 18 show adult, otherwise show underage.
Ideas:
(1). Accept a number from the keyboard
(2). Determine if the above conditions are met
Year>=18
(3). Show adult or minor according to judgment
2. Display: Can you run over the leopard? Receive input, if the input is "can", you are more animals than animals. If the input "cannot" show the beast is inferior.
Ideas:
(1). Output text "Can you run over the leopard?" ”
(2). Receive text from the keyboard
(3). Determine if the above conditions are met
s== can
(4). Judging results show "You are more animals than animals", "You animals are inferior"
3. Let the user enter a year to determine whether it is leap years.
A. can be divisible by 400
B. can be divisible by 4, but not divisible by 100.
Ideas:
(1). Receives a year from the keyboard, and converts the whole number of years.
(2). Determine if the above two conditions are met.
(year%400 = = 0) | | (Year%4==0 && year%100!=0)
(3). Show "Common Year" "Leap year" according to the judging result
4. Standard weight (KG) = height (CM)-100 floating up and down 5 kg normal.
Enter the actual weight, enter the actual height, "standard" or "non-standard".
Ideas:
(1). Enter height (h) and weight (W).
(2). Calculate the standard weight = height-100. bw=h-100;
(3). Compare the standard weight to the actual weight. Bw-w>=-5 && bw-w<=5
(4). Display standard or not standard.
C # Statements: Branching