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 exam_24_04
- {
- class Program
- {
- static void Main(string[] args)
- {
- var a = double.Parse(Console.ReadLine());
- var b = double.Parse(Console.ReadLine());
- var operation = Console.ReadLine();
- switch (operation)
- {
- case "+":
- Console.WriteLine("{0} {1} {2} = {3} - {4}", a, operation, b, a + b, (a + b) % 2 == 0 ? "even" : "odd"); break;
- case "-":
- Console.WriteLine("{0} {1} {2} = {3} - {4}", a, operation, b, (a - b), (a - b) % 2 == 0 ? "even" : "odd"); break;
- case "*":
- Console.WriteLine("{0} {1} {2} = {3} - {4}", a, operation, b, a * b, (a * b) % 2 == 0 ? "even" : "odd"); break;
- case "/":
- if (b == 0)
- {
- Console.WriteLine("Cannot divide {0} by zero", a);break;
- }
- else
- {
- Console.WriteLine("{0} {1} {2} = {3:f2}", a, operation, b, a / b); break;
- }
- case "%":
- if (b == 0)
- {
- Console.WriteLine("Cannot divide {0} by zero", a); break;
- }
- else
- {
- Console.WriteLine("{0} {1} {2} = {3}", a, operation, b, a % b); break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement