// page 141 logical operations and or not // page 142 if statments // page 139 relationals > < >= <= != == // = assigns a value // == in equality to tests a value page 139 // === in quality to tests a value strictly to the type. In.Net Core and C# this would be the equivalent of ReferenceEquals(var1,var2) method // do while // 2 control variables // we are using the do/while to test if the userAge is an int int userAge; bool isValidInput = false; do { Console.WriteLine("Enter your age: "); #pragma warning disable CS8600 string input = Console.ReadLine(); // warning //inherited from ReadLine() not string input; // if return true userAge // if return false input #pragma warning restore CS8600 if (int.TryParse(input, out userAge)) { isValidInput = true; Console.WriteLine($"You entered: {userAge}"); // template variable in the view. Ignore type str + int } // if else { Console.WriteLine("Invalid entry. Please enter a valid number between 1 and 120."); } // else } // do while ( !isValidInput ); int age = userAge; // Method 1 using Convert // int age = Convert.ToInt32(userAge); // age < 18 nothing // age >= 18 and < 21 vote // age >= 21 and < 65 vote and drink // age 65 or > vote, drink retire // if age < 18 lambda exp with no false // if (age < 18) if (age > 0 & age < 18) { Console.WriteLine("You can not vote, drink or retire"); } else if (age >= 18 & age < 21) { Console.WriteLine("You can vote, but not drink or retire"); } else if (age >= 21 & age < 65) { Console.WriteLine("You can vote and drink but not retire"); } else if (age >= 65 & age < 120) { Console.WriteLine("You can vote, drink and retire"); } else { Console.WriteLine("Invalid entry"); } // switch page 145 Console.WriteLine("Enter customer type (C,R,W): "); string userInput = Console.ReadLine(); // string input Console.WriteLine("You entered: " + userInput); string customertype = userInput; // control switch (customertype) // condition // operations or expressions { // cases do NOT have to be sorted for usability, but a best practice for readability // Big 3 for Best Practices // readability framework resource(pu/memory) case "C": Console.WriteLine("Customer"); break; case "R": Console.WriteLine("Retailer"); break; case "W": Console.WriteLine("Wholesaler"); break; // default No Match default: Console.WriteLine("No Customer Type Defined"); break; } // switch