Advertisement
Guest User

SimpleCalculator

a guest
Jan 24th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.14 KB | None | 0 0
  1. using System;
  2.  
  3. namespace SimpleCalc
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             Console.Write("Enter first number: ");
  10.             int a = int.Parse(Console.ReadLine());
  11.             Console.Write("Enter second number: ");
  12.             int b = int.Parse(Console.ReadLine());
  13.             Console.Write("Choice operation: ");
  14.             string choice = Console.ReadLine();
  15.            
  16.             switch (choice)
  17.             {
  18.                 case "+":
  19.                     {
  20.                         Console.WriteLine("Result: " + (a + b));
  21.                         Console.ReadKey(true);
  22.                         break;
  23.                     }
  24.                 case "*":
  25.                     {
  26.                         Console.WriteLine("Result: "+(a * b));
  27.                         Console.ReadKey(true);
  28.                         break;
  29.                     }
  30.                 default:
  31.                     {
  32.                         Console.Write("Invalid operation !");
  33.                         Console.ReadKey(true);
  34.                         break;
  35.                     }
  36.             }
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement