0% found this document useful (0 votes)
75 views6 pages

06 Task Performance 1 Event Driven

Uploaded by

zeezien9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
75 views6 pages

06 Task Performance 1 Event Driven

Uploaded by

zeezien9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Task Performance Private

Assemblies
# INSTRUCTIONS OUTPUT
1. Create a program named
BasicCalculator. The
program should only
have one (1) Windows
form named
FrmBasicCalculator. See
Figure 1 for the sample
design of the form.

2. Navigate on the Solution


Explorer and create another
project file for a private
assembly named
CalculatorPrivateAssembly.

3. Rename Class1 to
BasicComputation. After
that, create four (4) static
methods that return the
results of Addition,
Subtraction,
Multiplication, and
Division, wherein the data
type is a float data type.
4. Build your private assembly.

5. Go to your
FrmBasicCalculator and
reference the created
private assembly.

6. Import the private


assembly in the class of
FrmBasicCalculator and
call all the methods to
display the expected
output.

7. Your program should be


able to add, subtract,
multiply, and divide. See
Table 1 for sample output
COD
E
//FORM1.cs
using CalculatorPrivateAssembly;

namespace BasicCalculator
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)


{
tbResult.Text = "Total:" + Environment.NewLine + "000000";
}

private void button1_Click(object sender, EventArgs e)


{
string oper =
cbOperation.Text; switch
(oper)
{
case "+":
BasicComputation a = new BasicComputation();
tbResult.Text = "Total:" + Environment.NewLine + Convert.ToDouble
(a.Addition((float)Convert.ToDouble(tbNum1.Text),
(float)Convert.ToDouble(tbNum2.Text)));
break;
case "-":
BasicComputation b = new BasicComputation();
tbResult.Text = "Total:" + Environment.NewLine + Convert.ToDouble
(b.Subtraction((float)Convert.ToDouble(tbNum1.Text),
(float)Convert.ToDouble(tbNum2.Text)));
break;
case "*":
BasicComputation c = new BasicComputation();
tbResult.Text = "Total:" + Environment.NewLine + Convert.ToDouble
(c.Multiplication((float)Convert.ToDouble(tbNum1.Text),
(float)Convert.ToDouble(tbNum2.Text)));
break;
case "/":
BasicComputation d = new BasicComputation();
tbResult.Text = "Total:" + Environment.NewLine + Convert.ToDouble
(d.Division((float)Convert.ToDouble(tbNum1.Text),
(float)Convert.ToDouble(tbNum2.Text)));
break;
default:
MessageBox.Show("Operator is
invalid"); break;
}
}
}
}

//BasicComputation.cs
namespace CalculatorPrivateAssembly
{
public class BasicComputation
{
public float Addition(float num1, float num2)
{
float result = num1 + num2;
return result;
}
public float Subtraction(float num1, float num2)
{
float result = num1 - num2;
return result;
}
public float Multiplication(float num1, float num2)
{
float result = num1 * num2;
return result;
}
public float Division(float num1, float num2)
{
float result = num1 / num2;
return result;
}
}
}

You might also like