Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp5
- {
- class Program
- {
- static void Main(string[] args)
- {
- double n1 = double.Parse(Console.ReadLine());
- double n2 = double.Parse(Console.ReadLine());
- char function = char.Parse(Console.ReadLine());
- double result = 0.0;
- string evenOdd = "neutral";
- if (function != '/')
- {
- if (function == '+')
- {
- result = n1 + n2;
- }
- else if (function == '-')
- {
- result = n1 - n2;
- }
- else if (function == '*')
- {
- result = n1 * n2;
- }
- else if (function == '%')
- {
- result = n1 % n2;
- }
- if (result % 2 == 0)
- {
- evenOdd = "even";
- }
- else
- {
- evenOdd = "odd";
- }
- Console.WriteLine($"{n1} {function} {n2} = {result} - {evenOdd}");
- }
- else if (function == '/' && n2!=0)
- {
- result = n1 / n2;
- Console.WriteLine($"{n1} {function} {n2} = {result:F2}");
- }
- else if (n2 == 0 && function == '/')
- {
- Console.WriteLine($"Cannot divide {n1} by zero");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement