Example Calculator in C# (Sharp) Console and Code
Example a simple calculator in C# (Sharp) Application Console + Code.
For just they enter world of the programming I leave the code them, We created a menu soon and the method since this will give back a value of the mathematical operations.
First it does not ask to enter the values
Soon
You choose an option.
1º) Extreme
2º) Subtraction
3º) Multiplication
4º) Division
And later it will print the answer to us.
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace calculator \ { class Program \ { //Metodos to give back a value static int Extreme (int to, int b) \ { int sum = to + b; return sum; } static int Resta (int to, int b) \ { int remains = to - b; return remains; } static int Multi (int to, int b) \ { int multi = to * b; return multi; } static int Division (int to, int b) \ { int divi = to/b; return divi; } //Main the main one static void Main (string [] args) \ { int to, b; Console.Write (“ENTERS FIRST VALUE: �); a = int. Parse (Console.ReadLine ()); Console.Write (“ENTERS SECOND VALUE: �); b = int. Parse (Console.ReadLine ()); Console.Write (“1º) Extreme� + “\ n� + “2º) Subtraction� + “\ n� + “3º) Multiplication� + “\ n� + “4º) Division� + “<strong> \ n�); Console.Write (“Selects an option: �); switch (Console.Read ()) \ { ‘1’ marries: Console.Write (“Extreme =� + Sum (to, b)); //To continue logical and to extract //methods break; it marries ‘2’: Console.Write (“Subtraction =� + Resta (to, b)); //To continue logical and to extract //methods break; it marries ‘3’: Console.Write (“Multiplication =� + Multi (to, b)); //To continue logical and to extract //methods break; it marries ‘4’: Console.Write (“Division =� + Division (to, b)); //To continue logical and to extract //methods break; } Console.ReadKey (); //pausee to press the key } }}
Â