Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Operations_with_Numbers
- {
- class Program
- {
- static void Main(string[] args)
- {
- var n1 = int.Parse(Console.ReadLine()); // 0...40 000
- var n2 = int.Parse(Console.ReadLine()); // 0...40 000
- var operatoor = Console.ReadLine(); // + , -, *, /, %
- double result = 0;
- string parity = "odd";
- if ((operatoor == "+") || (operatoor == "-") || (operatoor == "*"))
- {
- if (operatoor == "+")
- {
- result = n1 + n2;
- if ((result % 2 == 0)) parity = "even";
- }
- if (operatoor == "-")
- {
- result = n1 - n2;
- if ((result % 2 == 0)) parity = "even";
- }
- if (operatoor == "*")
- {
- result = n1 * n2;
- if ((result % 2 == 0)) parity = "even";
- }
- Console.WriteLine($"{n1} {operatoor} {n2} = {result} – {parity}");
- }
- if (n2 == 0)
- {
- Console.WriteLine($"Cannot divide {n1} by zero");
- Environment.Exit(0);
- }
- if (operatoor == "/")
- {
- result = 1.0 * n1 / n2;
- Console.WriteLine($"{n1} / {n2} = {result:f2}");
- }
- if (operatoor == "%")
- {
- result = n1 % n2;
- Console.WriteLine($"{n1} % {n2} = {result}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement