Create a dynamic website that functions like a calculator Ad

Create a dynamic website that functions like a calculator. Add features for addition, subtraction, multiplication, division, modulation, and so on. This is for C# using visual studio.

Solution

Any queries please comment

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
namespace calc
{
[WebService(Namespace = \"mycalculatorexample.org\")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class CalcWebService : System.Web.Services.WebService
{
[WebMethod]
public string calculate(string first, string second, char sign)
{
string result;
switch (sign)
{
case \'+\':
{
result = (Convert.ToInt32(first) + Convert.ToInt32(second)).ToString();
break;
}
case \'-\':
{
result = (Convert.ToInt32(first) - Convert.ToInt32(second)).ToString();
break;
}
case \'*\':
{
result = (Convert.ToInt32(first) * Convert.ToInt32(second)).ToString();
break;
}
case \'/\':
{
result = (Convert.ToInt32(first) / Convert.ToInt32(second)).ToString();
break;
}
case \'%\':
{
result = (Convert.ToInt32(first) % Convert.ToInt32(second)).ToString();
break;
}
default:
result = \"Invalid\";
break;
}
return result;
}
}

Now, write the following code in the .cs file.

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 Calculator
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string i, j;
static char c;
private void btnthree_Click(object sender, EventArgs e)
{
textBox1.Text += Convert.ToString(3);
}
private void btnone_Click(object sender, EventArgs e)
{
textBox1.Text += Convert.ToString(1);
}
private void btntwo_Click(object sender, EventArgs e)
{
textBox1.Text += Convert.ToString(2);
}
private void btnfour_Click(object sender, EventArgs e)
{
textBox1.Text += Convert.ToString(4);
}
private void btnfive_Click(object sender, EventArgs e)
{
textBox1.Text += Convert.ToString(5);
}
private void btnsix_Click(object sender, EventArgs e)
{
textBox1.Text += Convert.ToString(6);
}
private void btnseven_Click(object sender, EventArgs e)
{
textBox1.Text += Convert.ToString(7);
}
private void btneight_Click(object sender, EventArgs e)
{
textBox1.Text += Convert.ToString(8);
}
private void btnnine_Click(object sender, EventArgs e)
{
textBox1.Text += Convert.ToString(9);
}
private void btnzero_Click(object sender, EventArgs e)
{
textBox1.Text += Convert.ToString(0);
}
private void btnplus_Click(object sender, EventArgs e)
{
i = textBox1.Text;
textBox1.Text = \"\";
c = \'+\';
}
private void btnminuse_Click(object sender, EventArgs e)
{
i = textBox1.Text;
textBox1.Text = \"\";
c = \'-\';
}
private void btnmultiply_Click(object sender, EventArgs e)
{
i = textBox1.Text;
textBox1.Text = \"\";
c = \'*\';
}
private void btndivide_Click(object sender, EventArgs e)
{
i = textBox1.Text;
textBox1.Text = \"\";
c = \'/\';
}
private void btnmodulo_Click(object sender, EventArgs e)
{
i = textBox1.Text;
textBox1.Text = \"\";
c = \'%\';
}
private void btnequal_Click(object sender, EventArgs e)
{
j = textBox1.Text;
calclocalhost.CalcWebService obj = new calclocalhost.CalcWebService();
textBox1.Text = obj.calculate(i, j, c);
}
}
}

Create a dynamic website that functions like a calculator. Add features for addition, subtraction, multiplication, division, modulation, and so on. This is for
Create a dynamic website that functions like a calculator. Add features for addition, subtraction, multiplication, division, modulation, and so on. This is for
Create a dynamic website that functions like a calculator. Add features for addition, subtraction, multiplication, division, modulation, and so on. This is for

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site