Advertisement
denitsas01

Untitled

Mar 29th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.37 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 OperationsBetweenNumbers
  8. {
  9.     class OperationsBetweenNumbers
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             double n1 = double.Parse(Console.ReadLine());
  14.             double n2 = double.Parse(Console.ReadLine());
  15.             char symbol = char.Parse(Console.ReadLine());
  16.             double result = 0;
  17.             double ostatak = 0;
  18.             string evenORodd = string.Empty;
  19. ;
  20.             if (symbol == '+' || symbol =='-' || symbol == '*')
  21.             {
  22.                 if (n1 % 2 == 0 && n2 % 2 == 0)
  23.                 {
  24.                     evenORodd = "even";
  25.                     Console.WriteLine($"{n1}{symbol}{n2} = {result} - {evenORodd}");
  26.                 }
  27.                 else if (n1 % 10 == 5 && n2 % 10 == 5)
  28.                 {
  29.                     evenORodd = "odd";
  30.                     Console.WriteLine($"{n1}{symbol}{n2} = {result} - {evenORodd}");
  31.                 }
  32.             }
  33.             else if (symbol == '/') Console.WriteLine($"{n1} / {n2} = {Math.Round(result,2)}");
  34.             else if (symbol == '%') Console.WriteLine($"{n1} % {n2} = {ostatak}");
  35.             else if (symbol == '/' || symbol == '%' && n2 != 0) Console.WriteLine($"Cannot divide {n1} by zero");
  36.            
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement