Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Operations_Between_Numbers
- {
- class Program
- {
- static void Main(string[] args)
- {
- double n1 = double.Parse(Console.ReadLine());
- double n2 = double.Parse(Console.ReadLine());
- string operation = Console.ReadLine();
- double total = 0;
- string EvenOdd = string.Empty;
- switch (operation)
- {
- case "+":
- total = n1 + n2;
- break;
- case "-":
- total = n1 - n2;
- break;
- case "*":
- total = n1 * n2;
- break;
- case "/":
- total = n1 / n2;
- break;
- case "%":
- total = n1 % n2;
- break;
- }
- if (operation == "+" || operation == "-" || operation == "*")
- {
- if (total % 2 == 0)
- {
- EvenOdd = "even";
- }
- else
- {
- EvenOdd = "odd";
- }
- Console.WriteLine($"{n1} {operation} {n2} = {total} - {EvenOdd}");
- }
- else if (operation == "/")
- {
- if (n1 != 0)
- {
- Console.WriteLine($"{n1} {operation} {n2} = {total:f2}");
- }
- else
- {
- Console.WriteLine($"Cannot divide {n1} by zero");
- }
- }
- else if (operation == "%")
- if (n1 != 0)
- {
- Console.WriteLine($"{n1} {operation} {n2} = {total}");
- }
- else
- {
- Console.WriteLine($"Cannot divide {n1} by zero");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment