// Storage
int value1 = 0;
int value2 = 0;
int total = 0;
string operation;
// Get first number
value1 = GetNumber();
// Get Operation
Console.Write("What operation would you like to perform: ");
operation = Console.ReadLine();
// Get second number
value2 = GetNumber();
// Perform the operation
if (operation == "+")
total = value1 + value2; // Addition
else if (operation == "-")
total = value1 - value2; // Subtraction
else if (operation == "/")
total = value1 / value2; // Division
else if (operation == "*")
total = value1 * value2; // Multiplication
else
{
// Ignore other keypresses
}
// Output the answer
Console.WriteLine("The total is {0}", total);
Showing posts with label A simple Calculator. Show all posts
Showing posts with label A simple Calculator. Show all posts
Tuesday, September 13, 2011
Subscribe to:
Posts (Atom)
Popular 5 Posts Last 7 days
-
Give the demonstration for the various Dialog Box avail with C# Smart Device Application. Nagpur University MCA V Semester, C#.Net, E...
-
Assemblies In the applications that you build within the .NET Framework, assemblies will always play an important role. Assemblies can be th...
-
The structure of an assembly Assemblies contain code that is executed by the Common Language Runtime . The great thing about assemblies is ...
-
greatest element of given matrix #include<stdio.h> #include<conio.h> main() { int a[5][5],m,n,i,j,big; clrscr(); pr...
-
Tweet to take part in the #anything4jetta contest What will u do to win the all-new Jetta All the new Jetta can be yours, with th...