Created
May 29, 2018 02:04
-
-
Save janell-baxter/19c41e88818ab745e5f9732d673973b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Application using example code from C# 5.0 Pocket Reference, page 28 | |
//http://shop.oreilly.com/product/0636920023975.do | |
using System; | |
namespace UmbrellaWizard | |
{ | |
class Program | |
{ | |
static void Main() | |
{ | |
bool Rainy = false; | |
bool Sunny = false; | |
bool Windy = false; | |
bool Umbrella = false; | |
string input; | |
Console.WriteLine(":::::::::::::: Umbrella Wizard! ::::::::::::::"); | |
Console.Write("How's the weather outside? Is it rainy? (yes or no)"); | |
input = Console.ReadLine(); | |
if (input == "yes") | |
{ | |
Rainy = true; | |
} | |
Console.Write("Is it sunny? (yes or no)"); | |
input = Console.ReadLine(); | |
if (input == "yes") | |
{ | |
Sunny = true; | |
} | |
Console.Write("Is it windy? (yes or no)"); | |
input = Console.ReadLine(); | |
if (input == "yes") | |
{ | |
Windy = true; | |
} | |
Umbrella = UseUmbrella(Rainy, Sunny, Windy); | |
if (Umbrella) | |
{ | |
Console.WriteLine("The umbrella wizard says take an umbrella with you!"); | |
} | |
else | |
{ | |
Console.WriteLine("The umbrella wizard says no umbrella today!"); | |
} | |
//the next line keeps the console window open while you are testing in Visual Studio | |
Console.ReadKey(); | |
} | |
static bool UseUmbrella(bool rainy, bool sunny, bool windy) | |
{ | |
return !windy && (rainy || sunny); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment