Advertisement
plamen83

Untitled

Mar 22nd, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.93 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _03.operationsBetweenNumbers
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var N1 = double.Parse(Console.ReadLine());
  14.             var N2 = double.Parse(Console.ReadLine());
  15.             var operation = Console.ReadLine();
  16.  
  17.             if (operation == "+")
  18.             {
  19.                 Console.Write("{0} {1} {2} = {3} ", N1, operation, N2, N1 + N2);
  20.  
  21.                 if ((N1 + N2) % 2 == 0)
  22.                     Console.WriteLine("- even");
  23.                 else
  24.                     Console.WriteLine("- odd");
  25.             }
  26.  
  27.             else if (operation == "-")
  28.             {
  29.                 Console.Write("{0} {1} {2} = {3} ", N1, operation, N2, N1 - N2);
  30.  
  31.                 if ((N1 - N2) % 2 == 0)
  32.                     Console.WriteLine("- even");
  33.                 else
  34.                     Console.WriteLine("- odd");
  35.             }
  36.  
  37.             else if (operation == "*")
  38.             {
  39.                 Console.Write("{0} {1} {2} = {3} ", N1, operation, N2, N1 * N2);
  40.  
  41.                 if ((N1 * N2) % 2 == 0)
  42.                     Console.WriteLine("- even");
  43.                 else
  44.                     Console.WriteLine("- odd");
  45.             }
  46.  
  47.             else if (operation == "/")
  48.  
  49.                 if (N2 == 0)
  50.                     Console.WriteLine("Cannot divide {0} by zero", N1);
  51.  
  52.                 else
  53.                 {
  54.                    
  55.                     Console.WriteLine("{0} {1} {2} = {3} ", N1, operation, N2, (double)N1 / N2);
  56.                 }
  57.  
  58.             else if (operation == "%")
  59.                 if (N2 == 0)
  60.                     Console.WriteLine("Cannot divide {0} by zero", N1);
  61.  
  62.                 else
  63.  
  64.                     Console.WriteLine("{0} {1} {2} = {3} ", N1, operation, N2, N1 % N2);
  65.  
  66.  
  67.  
  68.  
  69.         }
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement