C# Lesson 4
Matt Bauer 1/8/2020
It's time to learn what a Boolean is!
In Lesson 4 I'll be introducing another datatype. The bool!
using System;
namespace Lesson4
{
class TrueAndFalse
{
static void Main(string[] args)
{
// true, false
// 1 , 0
bool trueValue = true;
Console.WriteLine("This is a true value:\t" + trueValue);
bool falseValue = false;
Console.WriteLine("This is a false value:\t" + falseValue);
/* Comparison Operators
* ==, IS EQUAL TO
* !=, IS NOT EQUAL TO
* >, GREATER THAN
* <, LESS THAN
* >=, GREATER THAN OR EQUAL TO
* <=, LESS THAN OR EQUAL TO
*/
bool value1 = 7 == 7;
Console.WriteLine("7 IS EQUALE TO 7:\t" + value1);
bool value2 = 7 != 7;
Console.WriteLine("7 IS NOT EQUAL TO 7: \t" + value2);
bool value3 = 99 > 1;
Console.WriteLine("99 IS GREATER THAN 1:\t" + value3);
bool value4 = 99 < 1;
Console.WriteLine("99 IS LESS THAN 1:\t" + value4);
bool value5 = 2 >= 1;
Console.WriteLine("2 is greaterthan or equal to 1: " + value5);
bool value6 = 2 <= 2;
Console.WriteLine("2 is lessthan or equal to 2: " + value6);
bool value7 = "cup" == "CUP";
Console.WriteLine("cup is equal to CUP: " + value7);
}
}
}
/*
* TASK:
* Below, you will see comparison statements written in english being displayed by Console.WriteLine.
* Make a bool variable that executes the comparison described in the Console.WriteLine.
* Then concatinate the bool to the end of the string.
*/
using System;
namespace Lesson4Task
{
class TrueAndFalseTask
{
static void Main(string[] args)
{
Console.WriteLine("7 is greater than 9: ");
Console.WriteLine("12 is less than 15: ");
Console.WriteLine("91 is greater than or equal to 19: ");
Console.WriteLine("1.2 is not equal to 6.6: ");
Console.WriteLine("17.9 is less than or equal to 17.91: ");
Console.WriteLine("7.5 is greater than 7.4: ");
Console.WriteLine("ball equals BALL: ");
Console.WriteLine("cup equals cup: ");
Console.WriteLine("pan is not equal to Pan: ");
}
}
}