Presentation is loading. Please wait.

Presentation is loading. Please wait.

Clear and Unclear Windows

Similar presentations


Presentation on theme: "Clear and Unclear Windows"— Presentation transcript:

1 Clear and Unclear Windows
1

2 Branching Statements

3 The if / else if / else branching statement
if ( bool-expression ) { statement(s) } else

4 The if / else if / else branching statement
if ( bool-expression1 ) { statement(s) } else if (bool-expression2 ) else

5 Your task… New project named branches
Write a quick and simple calculator program: Display the message “If statement calculator…” Ask the user for a number (save it) Ask the user for a 2nd number (save it) Ask the user what math operation to do ( +, -, *, / ) Provide an error message if the user doesn’t enter a valid operator Use an if /else if /else to display the answer

6 The switch branching statement
switch ( variable ) { case <option 1>: <code> break; case <option 2>: default: }

7 The switch branching statement
switch ( variable ) { case <option 1>: <code> break; case <option 2>: default: } switch ( userName) { case “Korben Dallas”: Console.WriteLine(“LeeLoo loves you”); break; case “Zorg”: Console.WriteLine(“LeeLoo will destroy you”); default: Console.WriteLine(“Be careful!”); }

8 Your task continued… Create a new project named switch:
Do the same thing again, write a simple calculator program Use a switch instead of an if Display the message “Switch statement calculator…”

9 Clear and Unclear Windows


Download ppt "Clear and Unclear Windows"

Similar presentations


Ads by Google