Advertisement
Guest User

Untitled

a guest
Dec 27th, 2018
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.22 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 _09Operations_Between_Numbers
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             double N1 = int.Parse(Console.ReadLine());
  14.             double N2 = int.Parse(Console.ReadLine());
  15.             string operation = Console.ReadLine();
  16.             double result = 0;
  17.  
  18.  
  19.             if (operation == "+")
  20.             {
  21.                 result = N1 + N2;
  22.                 if (result % 2 == 0)
  23.                 {
  24.                     Console.WriteLine($"{N1} {operation} {N2} = {result} - even");
  25.                 }
  26.                 else if (result % 2 == 1)
  27.                 {
  28.                     Console.WriteLine($"{N1} {operation} {N2} = {result} - odd");
  29.                 }
  30.             }
  31.  
  32.             if (operation == "-")
  33.             {
  34.                 result = N1 - N2;
  35.                 if (result % 2 == 0)
  36.                 {
  37.                     Console.WriteLine($"{N1} {operation} {N2} = {result} - even");
  38.                 }
  39.                 else if (result % 2 == 1)
  40.                 {
  41.                     Console.WriteLine($"{N1} {operation} {N2} = {result} - odd");
  42.                 }
  43.             }
  44.             if (operation == "*")
  45.             {
  46.                 result = N1 * N2;
  47.  
  48.                 if (result % 2 == 0)
  49.                 {
  50.                     Console.WriteLine($"{N1} {operation} {N2} = {result} - even");
  51.                 }
  52.                 else if (result % 2 == 1)
  53.                 {
  54.                     Console.WriteLine($"{N1} {operation} {N2} = {result} - odd");
  55.                 }
  56.             }
  57.             if (N2 == 0)
  58.             {
  59.                 Console.WriteLine($"Cannot divide { N1} by zero");
  60.  
  61.             }
  62.             else if (operation == "/")
  63.                 {
  64.                     result = N1 / N2;
  65.                     Console.WriteLine($"{N1} / {N2} = {result:F2}");
  66.                 }
  67.  
  68.                 else if (operation == "%")
  69.                 {
  70.                     result = N1 % N2;
  71.  
  72.                     Console.WriteLine($"{N1} % {N2} = {result}");
  73.                 }
  74.                
  75.  
  76.            
  77.         }
  78.     }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement