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