Advertisement
-Annie-

Calculator

Jun 12th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.86 KB | None | 0 0
  1. namespace Homework2
  2. {
  3.     using System;
  4.  
  5.     public class Problem
  6.     {
  7.         public static void Main()
  8.         {
  9.             int num1 = int.Parse(Console.ReadLine());
  10.             string operation = Console.ReadLine();
  11.             int num2 = int.Parse(Console.ReadLine());
  12.             int result = 0;
  13.  
  14.             switch (operation)
  15.             {
  16.                 case "+":
  17.                     result += num1 + num2;
  18.                     break;
  19.                 case "-":
  20.                     result += num1 - num2;
  21.                     break;
  22.                 case "*":
  23.                     result += num1 * num2;
  24.                     break;
  25.                 case "/":
  26.                     result += num1 / num2;
  27.                     break;
  28.             }
  29.  
  30.             Console.WriteLine(num1 + " " + operation + " " + num2 + " = " + result);
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement