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 _03.OperationsWithNumbers
- {
- class Program
- {
- static void Main(string[] args)
- {
- var n1 = int.Parse(Console.ReadLine());
- var n2 = int.Parse(Console.ReadLine());
- string operation = Console.ReadLine();
- double sum = 0;
- if (operation == "+")
- {
- sum = n1 + n2;
- if (sum % 2 == 0)
- {
- Console.WriteLine("{0} + {1} = {2} - even", n1, n2, sum);
- }
- else
- {
- Console.WriteLine("{0} + {1} = {2} - odd", n1, n2, sum);
- }
- }
- else if (operation == "-")
- {
- Console.Write($"{n1} - {n2} = {n1 - n2} - ");
- Console.WriteLine((n1 - n2) % 2 == 0 ? "even" : "odd");
- }
- else if (operation == "*")
- {
- sum = n1 * n2;
- if (sum % 2 == 0)
- {
- Console.WriteLine("{0} * {1} = {2} - even", n1, n2, sum);
- }
- else
- {
- Console.WriteLine("{0} * {1} = {2} - odd", n1, n2, sum);
- }
- }
- else if (operation == "/")
- {
- if (n2 == 0)
- {
- Console.WriteLine("Cannot divide {0} by zero", n1);
- }
- else
- {
- sum = n1 / n2;
- Console.WriteLine("{0} / {1} = {2}", n1, n2, sum);
- }
- }
- else if (operation == "%")
- {
- if (n2 == 0)
- {
- Console.WriteLine("Cannot divide {0} by zero", n1);
- }
- else
- {
- sum = n1 % n2;
- Console.WriteLine("{0} % {1} = {2}", n1, n2, sum);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement