namespace If-Else Statement Basics { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private readonly Random r = new(); private void CmdShow1_Click(object sender, EventArgs e) { int x = r.Next(7, 13); LblShow.ForeColor = Color.Black; LblShow.Text = "Value: " + x + "\n"; if (x > 9) { LblShow.Text += "doubledigit"; LblShow.ForeColor = Color.Red; } } private void CmdShow2_Click(object sender, EventArgs e) { int x = r.Next(7, 13); LblShow.Text = "Value: " + x + "\n"; if (x > 9) { LblShow.Text += "doubledigit"; LblShow.ForeColor = Color.Red; } else { LblShow.Text += "singledigit"; LblShow.ForeColor = Color.Blue; } } private void CmdShown3_Click(object sender, EventArgs e) { int x = r.Next(-3, 4); LblShow.ForeColor = Color.Black; LblShow.Text = "Value: " + x + "\n"; if (x > 0) LblShow.Text += "greater than 0"; else if (x < 0) LblShow.Text += "less than 0"; else LblShow.Text += "equal 0"; } private void CmdShown4_Click(object sender, EventArgs e) { int x = r.Next(-3, 4); LblShow.ForeColor = Color.Black; LblShow.Text = "Value: " + x + "\n"; LblShow.Text += x > 0 ? "greater than 0\n" : "less than 0 or equal 0\n"; LblShow.Text += x > 0 ? "greater than 0" : x < 0 ? "less than 0" : "equal 0"; } private void CmdShown5_Click(object sender, EventArgs e) { int x = r.Next(7, 13); int y = r.Next(7, 13); LblShow.ForeColor = Color.Black; LblShow.Text = "Valuee: " + x + " / " + y + "\n"; if (x > 9 && y > 9) LblShow.Text += "Both doubledigit"; else LblShow.Text += "At least one singledigit"; } private void CmdShown6_Click(object sender, EventArgs e) { int x = r.Next(7, 13); int y = r.Next(7, 13); LblShow.ForeColor = Color.Black; LblShow.Text = "Valuee: " + x + " / " + y + "\n"; if (x > 9 || y > 9) LblShow.Text += "One or both doubledigit"; else LblShow.Text += "Both singledigit"; } private void CmdShown7_Click(object sender, EventArgs e) { int x = r.Next(7, 13); int y = r.Next(7, 13); LblShow.ForeColor = Color.Black; LblShow.Text = "Valuee: " + x + " / " + y + "\n"; if (x > 9 ^ y > 9) LblShow.Text += "Just one doubledigit"; else LblShow.Text += "Both singledigit or both doubledigit"; } } }