Advertisement
Guest User

Untitled

a guest
Jan 30th, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.93 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApplication3
  4. {
  5.     class Calculator
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int x = int.Parse(Console.ReadLine());
  10.             char function = Console.ReadLine()[0];
  11.  
  12.             int y = int.Parse(Console.ReadLine());
  13.  
  14.             switch (function)
  15.             {
  16.                 case '+':
  17.                     Console.WriteLine($"{x} + {y} = {x + y}");
  18.                     break;
  19.                 case '-':
  20.                     Console.WriteLine($"{x} - {y} = {x-y}");
  21.                     break;
  22.                 case '*':
  23.                     Console.WriteLine($"{x} * {y} = {x*y}");
  24.                     break;
  25.                 case '/':
  26.                     Console.WriteLine($"{x} / {y} = {x/y}");
  27.                     break;
  28.                 default:
  29.                     Console.WriteLine("Invalid");
  30.                     break;
  31.             }
  32.  
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement