Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp2
- {
- class Program
- {
- static void Main(string[] args)
- {
- int num1 = int.Parse(Console.ReadLine());
- int num2 = int.Parse(Console.ReadLine());
- char operation = char.Parse(Console.ReadLine());
- double result = 0.0;
- if (operation == '+' || operation == '-' || operation == '*')
- {
- string evenOrOdd = "odd";
- if (operation == '+')
- {
- result = num1 + num2;
- }
- else if (operation == '-')
- {
- result = num1 - num2;
- }
- else if (operation == '*')
- {
- result = num1 * num2;
- }
- if (result % 2 == 0)
- {
- evenOrOdd = "even";
- }
- Console.WriteLine($"{num1} {operation} {num2} = {result} - {evenOrOdd}");
- }
- else if (num2 == 0)
- {
- Console.WriteLine($"Cannot divide {num1} by zero");
- }
- else if(operation == '/')
- {
- // / -> "{N1} / {N2} = {резултат:F2}"
- result = 1.0*num1 / num2;
- Console.WriteLine($"{num1} / { num2} = {result:F2}");
- }
- else
- {
- result = num1 % num2;
- // % -> "{N1} % {N2} = {остатък}"
- Console.WriteLine($"{num1} % {num2} = {result}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment