0% found this document useful (0 votes)
53 views5 pages

Using Using Using Using: System System - Collections.Generic System - Linq System - Text

The document contains code for creating a calculator library with addition and multiplication classes. The addition class takes two integers as arguments in the constructor, stores them as private fields, and has a public method to return their sum. The multiplication class follows the same pattern but returns the product of the two integers. The main method demonstrates creating instances of the addition and multiplication classes, calling their methods, and outputting the results. It also includes code for a Windows form with text boxes and a button to call the addition class and display the result.

Uploaded by

Arslan Azhar
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)
53 views5 pages

Using Using Using Using: System System - Collections.Generic System - Linq System - Text

The document contains code for creating a calculator library with addition and multiplication classes. The addition class takes two integers as arguments in the constructor, stores them as private fields, and has a public method to return their sum. The multiplication class follows the same pattern but returns the product of the two integers. The main method demonstrates creating instances of the addition and multiplication classes, calling their methods, and outputting the results. It also includes code for a Windows form with text boxes and a button to call the addition class and display the result.

Uploaded by

Arslan Azhar
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/ 5

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace CalculatorLibrary

public class Add

private int x;

private int y;

public Add(int a, int b)

x = a;

y = b;

public int sum()

return x + y;

////////////////////////////////////
using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace CalculatorLibrary

public class Multiplication

private int x;

private int y;

public Multiplication(int a, int b)

x = a;

y = b;

public int Mul()

return x * y;

///////////////////////////////
using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using CalculatorLibrary;

namespace Console_Cal

class Program

static void Main(string[] args)

int x = Convert.ToInt32(Console.ReadLine());

int y = Convert.ToInt32(Console.ReadLine());

int mul_x;

int add_x;

Add add = new Add(x,y);

Multiplication mul = new Multiplication(x,y);

add_x = add.sum();

mul_x= mul.Mul();

Console.WriteLine(add_x);

Console.WriteLine(mul_x);

}
/////////////////////////////

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;

using CalculatorLibrary;

namespace WindowsForms_cal

public partial class Form1 : Form

public Form1()

InitializeComponent();

private void Form1_Load(object sender, EventArgs e)

private void Btn_Add_Click(object sender, EventArgs e)

int x, y, result;
x = int.Parse(Text_x.Text);

y = int.Parse(Text_y.Text);

Add add = new Add(x,y);

result = add.sum();

Text_result.Text = result.ToString();

/////////////

You might also like