Advertisement
Qrist

Math operations

Apr 16th, 2020
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.79 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     public static void Main(string[] args)
  6.     {
  7.         double one = double.Parse(Console.ReadLine());
  8.         char ch = char.Parse(Console.ReadLine());
  9.         double two = double.Parse(Console.ReadLine());
  10.         Console.WriteLine(Mathoperations(one,ch,two));
  11.     }
  12.     public static double Mathoperations(double a,char ch,double b)
  13.     {
  14.         double result = 0.00;
  15.         switch(ch)
  16.         {
  17.             case '+':
  18.                 result = a + b;
  19.                 break;
  20.             case '-':
  21.                 result = a - b;
  22.                 break;
  23.             case '*':
  24.                 result = a * b;
  25.                 break;
  26.             case '/':
  27.                 result = a / b;
  28.                 break;
  29.         }
  30.         return result;
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement