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

Create a Windows application using C# visual studio that contains two textboxes

ID: 3693935 • Letter: C

Question

Create a Windows application using C# visual studio that contains two textboxes and three buttons. The textboxes should be used to allow the user to input two positive numeric values. The buttons should be labeled Add and Multiply and Reset. Create event-handler methods that retrieve the values, perform the calculations, and display the result of the calculations on a label. The result label should initially be set to be invisible with a font color of yellow. If invalid data is entered, change the font color to red on the result label and display a message saying “Value must be numeric and > 0.” When the final answer is displayed, the font color should be yel- low. Additional labels will be needed for the textboxes captions. Do not allow non-numeric characters to be entered. Invoke the TryParse( ) method to retrieve the values. All controls involved in program statements should be named. Right justify values in the textbox.

Explanation / Answer

form:
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:TextBox ID="textBox1" runat="server"
Width="335px" Height="41px"></asp:TextBox>
<asp:TextBox ID="textBox2" runat="server"
Width="335px" Height="41px"></asp:TextBox>
<asp:Button ID="b1" Text="add" runat="server" Height="37px"
Width="57px" />
<asp:Button ID="b2" Text="mul" runat="server" Height="37px"
Width="57px" />
<asp:Button ID="b3" Text="reset" runat="server" Height="37px"
Width="57px" />
<asp:Label ID="label1" Text="result" runat="server"
Font-Bold="False" Font-Italic="False" Font-Color="yellow"></asp:Label>
</body>
</html>

coding:
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 Arithmetic
{
public partial class ArthOperations : Form
{
public ArthOperations()
{
InitializeComponent();
label1.Enabled = false;
}
private void add(object sender, EventArgs e)
{
float first;
float second;
float output;   
first = Convert.ToInt32(textBox1.Text);
second = Convert.ToInt32(textBox2.Text);
output = first + second;
label1.Text=(output.ToString());
}


private void mul(object sender, EventArgs e) {
float first;
float second;
float output;
first = Convert.ToInt32(textBox1.Text);
second = Convert.ToInt32(textBox2.Text);
output = first * second;
label1.Text = (output.ToString());
}

private void reset(object sender, EventArgs e)
{
textBox1.Text = "";
textBox2.Text = "";
label1.Text = "";
}
}
}