Advertisement
Qrist

Calculation

Apr 15th, 2020
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.02 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. class Program
  5. {
  6.     public static void Main(string[] args)
  7.     {
  8.         string calculation = Console.ReadLine().ToLower();
  9.         int a = int.Parse(Console.ReadLine());
  10.         int b = int.Parse(Console.ReadLine());
  11.         switch (calculation)
  12.         {
  13.             case "add":
  14.                 Add(a, b);
  15.                 break;
  16.             case "subtract":
  17.                 Subtract(a, b);
  18.                 break;
  19.             case "multiply":
  20.                 Multyply(a, b);
  21.                 break;
  22.             case "divide":
  23.                 Divide(a, b);
  24.                 break;
  25.         }
  26.     }
  27.     public static void Add(int a,int b)
  28.     {
  29.         Console.WriteLine(a+b);
  30.     }
  31.     public static void Subtract(int a, int b)
  32.     {
  33.         Console.WriteLine(a-b);
  34.     }
  35.     public static void Multyply(int a, int b)
  36.     {
  37.         Console.WriteLine(a*b);
  38.     }
  39.     public static void Divide(int a, int b)
  40.     {
  41.         Console.WriteLine(a/b);
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement