// 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
-
greatest element of given matrix #include<stdio.h> #include<conio.h> main() { int a[5][5],m,n,i,j,big; clrscr(); pr...
-
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Fiveno { class Program { ...
-
Write the program for the Check-Box demonstration. Nagpur University MCA V Semester, C#.Net, Embedded System Programming, Nagpur Univ...
-
Nagpur University MCA V Semester, C#.Net, Embedded System Programming, Nagpur University Practical MCA V SEM using System; us...
-
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Numsearch { class Program {...
No comments:
Post a Comment