Presentation is loading. Please wait.

Presentation is loading. Please wait.

True / False Variables.

Similar presentations


Presentation on theme: "True / False Variables."— Presentation transcript:

1 True / False Variables

2 True / False Variables: Bool Variables
bool keepLooping; type name

3 True / False Variables: Bool Variables
bool keepLooping; keepLooping = true; while ( keepLooping == true ) { }

4 True / False Variables: Bool Variables
bool keepLooping; keepLooping = true; while ( keepLooping ) { }

5 True / False Variables: Bool Variables
bool haveValidInput; haveValidInput = false; while (haveValidInput == false) { }

6 True / False Variables: Bool Variables
bool haveValidInput; haveValidInput = false; while ( !haveValidInput ) { }

7 True / False Variables: Bool Variables
bool haveValidInput; haveValidInput = false; while ( !haveValidInput ) { }

8 True / False Variables: Bool Variables
bool haveValidInput; haveValidInput = false; while ( !haveValidInput ) { }

9 Logical Operators: And / Or

10 Logical Operators: And / Or

11 Logical Operators: And / Or

12 Logical Operators: And / Or
Example: if ( temp > 32 && temp < 50 ) isChilly = true; if ( temp < 32 || temp > 90 ) yuckyWeather = true;

13 Your task… New project named bool Write a program that :
Asks the user a yes/no question Loops until the user has entered a valid answer Which logical operator do you need to use in the loop condition check? Is this an “and” or an “or” question?

14 Your task continued… Add to your bool project…
Asks the user the yes/no question again Loop until the user has entered a valid answer This time, use a single bool variable as the loop control variable

15 Clear and Unclear Windows


Download ppt "True / False Variables."

Similar presentations


Ads by Google