// 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
-
// Storage int value1 = 0; int value2 = 0; int total = 0; string operation; // Get first number value1 = GetNumber(); // Get Operation Conso...
-
The Common Language Runtime Many different languages and platforms provide a runtime, and the .NET Framework is no exception. You will find,...
-
Assembly : - Assembly is a collection of classes developed in different languages & packaged as DLL to achieve a task. Assembly Arch...
-
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Sorting1 { class Program { ...
-
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...
No comments:
Post a Comment