Advertisement
EconomicSerg

Calculator in C#

Jan 21st, 2021
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1. using System;
  2.  
  3. namespace CalculatorInCSharp
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             Console.WriteLine("Enter a number: ");
  10.             int num1 = Convert.ToInt32(Console.ReadLine());
  11.  
  12.             Console.WriteLine("Enter another number: ");
  13.             int num2 = Convert.ToInt32(Console.ReadLine());
  14.  
  15.  
  16.             Console.WriteLine("Add, subtract, multiply, or divide? (Say in lower case letters)");
  17.             string type = Console.ReadLine();
  18.  
  19.             if (type == "add")
  20.             {
  21.                 Console.WriteLine(num1 + num2);
  22.             } else if (type == "subtract")
  23.             {
  24.                 Console.WriteLine(num1 - num2);
  25.             } else if (type == "multiply")
  26.             {
  27.                 Console.WriteLine(num1 * num2);
  28.             } else if (type == "divide")
  29.             {
  30.                 Console.WriteLine(num1 / num2);
  31.             } else
  32.             {
  33.                 Console.WriteLine("That isn't a type of math.");
  34.             }
  35.         }
  36.     }
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement