0% found this document useful (0 votes)
65 views2 pages

Basic Calculator Program in C#

The document describes a simple calculator program with the following functionality: - It displays a menu allowing the user to choose between addition, subtraction, multiplication, division or exit. - Depending on the user's selection, it will call the corresponding class to get two numbers from the user and display the result. - The classes firstnumber and secondnumber are used to get the first and second numbers from the user. - The classes sum, subtract, multiply and divide contain the logic for each calculation.

Uploaded by

Zubir Wahid
Copyright
© Attribution Non-Commercial (BY-NC)
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)
65 views2 pages

Basic Calculator Program in C#

The document describes a simple calculator program with the following functionality: - It displays a menu allowing the user to choose between addition, subtraction, multiplication, division or exit. - Depending on the user's selection, it will call the corresponding class to get two numbers from the user and display the result. - The classes firstnumber and secondnumber are used to get the first and second numbers from the user. - The classes sum, subtract, multiply and divide contain the logic for each calculation.

Uploaded by

Zubir Wahid
Copyright
© Attribution Non-Commercial (BY-NC)
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

bhd1001951.

zubir
using System; using [Link]; using [Link]; namespace simplecalculator { class Program { static void Main(string[] args) { int option; begin: [Link]("option 1: sum\noption 2: substract\noption 3: multiply\noption 4: divide\noption 5: exit"); [Link]("\ninsert your option: "); option = [Link]([Link]()); switch (option) { case 1: sum s = new sum(); [Link](); break; case 2: substract sub = new substract(); [Link](); break; case 3: multiply m = new multiply(); [Link](); break; case 4: divide d = new divide(); [Link](); break; case 5: [Link](0); break; default: [Link]("wrong option!"); [Link](); [Link](); goto begin; } [Link](); } } class firstnumber { public void getx(ref int x) { [Link]("\ninsert first number: "); x = [Link]([Link]()); } } class secondnumber { public void gety(ref int y)

[Link]
{ [Link]("insert second number: "); y = [Link]([Link]()); } } class sum { public void total() { int x = 0, y = 0; firstnumber a = new firstnumber(); [Link](ref x); secondnumber b = new secondnumber(); [Link](ref y); [Link]("\ntotal: {0}", x + y); } } class substract { public void total() { int x = 0, y = 0; firstnumber a = new firstnumber(); [Link](ref x); secondnumber b = new secondnumber(); [Link](ref y); [Link]("\ntotal: {0}", x - y); } } class multiply { public void total() { int x = 0, y = 0; firstnumber a = new firstnumber(); [Link](ref x); secondnumber b = new secondnumber(); [Link](ref y); [Link]("\ntotal: {0}", x * y); } } class divide { public void total() { int x = 0, y = 0; firstnumber a = new firstnumber(); [Link](ref x); secondnumber b = new secondnumber(); [Link](ref y); [Link]("\ntotal: {0}", x / y); } } }

You might also like