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