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