// 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);
Subscribe to:
Post Comments (Atom)
Popular 5 Posts Last 7 days
-
Type specifies the type of the data and the size of the data. Working with Data Types: Data Type specifies the type of the data and the size...
-
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 ...
-
Jit compilation The .NET Framework contains one or more JIT compilers that compile your IL code down to machine code, or code that is CPU-s...
-
Value Types Value types hold the data directly. Value types do not have default value. Value types will be stored in stack memory at compile...
No comments:
Post a Comment