Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Седма_задача___операции_между_числа
- {
- class Program
- {
- static void Main(string[] args)
- {
- double N1 = double.Parse(Console.ReadLine());
- double N2 = double.Parse(Console.ReadLine());
- double result = 0;
- string evenOrOdd = string.Empty;
- string operation = Console.ReadLine();
- if (operation == "+" || operation == "-" || operation == "*")
- {
- if (operation == "+")
- {
- result = N1 + N2;
- }
- else if (operation == "-")
- {
- result = N1 - N2;
- }
- else if (operation == "*")
- {
- result = N1 * N2;
- }
- if (result % 2 == 0)
- {
- evenOrOdd = "even";
- }
- else if (result % 2 != 0)
- {
- evenOrOdd = "odd";
- }
- Console.WriteLine($"{N1} {operation} {N2} = {result} - {evenOrOdd}");
- }
- else
- {
- if (operation == "/" && N2 != 0)
- {
- result = N1 / N2;
- Console.WriteLine($"{N1} / {N2} = {result:f2}");
- }
- else if (N2 == 0)
- {
- Console.WriteLine($"Cannot divide {N1} by zero");
- }
- else if (operation == "%")
- {
- result = N1 % N2;
- Console.WriteLine($"{N1} % {N2} = {result}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement