using System; using System.Windows.Forms; public class BooleanLogicForm : Form { private TextBox xInput, yInput; private Button calculateButton; private Label resultLabel; public BooleanLogicForm() { this.Text = "Boolean Operations"; this.Width = 300; this.Height = 250; Label xLabel = new Label() { Text = "Enter first number (x):", Top = 20, Left = 10, Width = 200 }; xInput = new TextBox() { Top = 40, Left = 10, Width = 100 }; Label yLabel = new Label() { Text = "Enter second number (y):", Top = 70, Left = 10, Width = 200 }; yInput = new TextBox() { Top = 90, Left = 10, Width = 100 }; calculateButton = new Button() { Text = "Calculate", Top = 130, Left = 10 }; calculateButton.Click += (sender, e) => Calculate(); resultLabel = new Label() { Top = 170, Left = 10, Width = 260, Height = 60 }; Controls.AddRange(new Control[] { xLabel, xInput, yLabel, yInput, calculateButton, resultLabel }); } private void Calculate() { if (int.TryParse(xInput.Text, out int x) && int.TryParse(yInput.Text, out int y)) { int and = x & y; int or = x | y; int xor = x ^ y; resultLabel.Text = $"{x} & {y} = {and}\n{x} | {y} = {or}\n{x} ^ {y} = {xor}"; } else { resultLabel.Text = "Please enter valid integers."; } } [STAThread] public static void Main() { Application.Run(new BooleanLogicForm()); } }