Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a Windows application that contains two text boxes and two command button

ID: 3698734 • Letter: C

Question

Create a Windows application that contains two text boxes and two command buttons. The text boxes should be used to allow the user to input two numeric values.The buttons should be labeled Add and Multiply. Create event-handler methods that retrieve the values, perform the calculations, and display the result of the calculations on a label.The label should initially be set to be invisible.Additional labels will be needed for the text boxes captions.

Please complete this assignment as actual C# application so you can compile and run them to see if you have any errors. Create and submit a zip file of your project folder.

Save and submit your work as instructed below.

This is for C#

Explanation / Answer

Please find my implementation:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Calculation
{
public partial class Form1 : Form
{
int number1, number2;
bool check1, check2;
String text1, text2;
public Form1()
{
InitializeComponent();
}

private void add_btn_Click(object sender, EventArgs e)
{
text1 = num1.Text;
check1 = int.TryParse(text1,out number1);
text2 = num2.Text;
check2 = int.TryParse(text2,out number2);

if (check1 == false || check2 == false || (number1 < 0 || number2 < 0))
{
result.Visible = true;
result.ForeColor = Color.Red;
result.Text = "Value must be numeric and > 0";
}
else
{
int res=number1+number2;
result.Visible = true;
result.ForeColor = Color.Yellow;
result.Text = res.ToString();
}
}

private void multiply_btn_Click(object sender, EventArgs e)
{
text1 = num1.Text;
check1 = int.TryParse(text1, out number1);
text2 = num2.Text;
check2 = int.TryParse(text2, out number2);

if (check1 == false || check2 == false || (number1 < 0 || number2 < 0))
{
result.Visible = true;
result.ForeColor = Color.Red;
result.Text = "Value must be numeric and > 0";
}
else
{
int res = number1 * number2;
result.Visible = true;
result.ForeColor = Color.Yellow;
result.Text = res.ToString();
}
}

private void reset_btn_Click(object sender, EventArgs e)
{
result.Visible = false;
num1.Text = "";
num2.Text = "";
}
}
}