Last active
February 20, 2017 00:07
-
-
Save janellbaxter/db02a4b782c963379c315e6283074a01 to your computer and use it in GitHub Desktop.
7.1 Conditional Statements; Programming is Fun: C# Adventure Game (Learn C#)
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
/* | |
* 7.1 Conditional Statements | |
* Example code from Programming is Fun: C# Adventure Game | |
* Learn C# (for beginners) | |
* http://programmingisfun.com/learn/c-sharp-adventure-game | |
*/ | |
using System; | |
namespace ConditionalStatements | |
{ | |
class Program | |
{ | |
static void Main() | |
{ | |
Test(); | |
} | |
static void Test() | |
{ | |
Console.Title = "Water Temperature Guide"; | |
int temperature = 0; | |
Console.Write("What is the temperature of the water? Enter a whole number: "); | |
temperature = Convert.ToInt16(Console.ReadLine()); | |
if (temperature <= 0) | |
{ | |
Console.WriteLine("Water will freeze; the freezing point of water is 0°C."); | |
} | |
else if (temperature >= 209) | |
{ | |
Console.WriteLine("Water is getting too hot; the leaves might cook and ruin the flavor!"); | |
} | |
else if (temperature >= 208) | |
{ | |
Console.WriteLine("A good temperature for brewing black tea."); | |
} | |
else if (temperature >= 180) | |
{ | |
Console.WriteLine("A good temperature for brewing oolong tea."); | |
} | |
else if (temperature >= 170) | |
{ | |
Console.WriteLine("A good temperature for brewing white and green teas."); | |
} | |
else | |
{ | |
Console.WriteLine("Water is not cold enough to freeze,"); | |
Console.WriteLine("nor a good temperature for brewing tea."); | |
} | |
Console.WriteLine("Press enter to continue..."); | |
Console.ReadKey(); | |
Test(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment