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 Operation_between_num
- {
- class Program
- {
- static void Main(string[] args)
- {
- double N1 = double.Parse(Console.ReadLine());
- double N2 = double.Parse(Console.ReadLine());
- char operations = char.Parse(Console.ReadLine());
- double result = 0;
- if ((operations=='+'))
- {
- result = N1 + N2;
- if (result%2==0)
- {
- Console.WriteLine($"{N1} {operations} {N2} = {result} - even ");
- }
- else if (result%2==1)
- {
- Console.WriteLine($"{N1} {operations} {N2} = {result} - odd ");
- }
- }
- else if (operations=='-')
- {
- result = N1 - N2;
- if (result % 2 == 0)
- {
- Console.WriteLine($"{N1} {operations} {N2} = {result} - even ");
- }
- else if (result % 2 == 1)
- {
- Console.WriteLine($"{N1} {operations} {N2} = {result} - odd ");
- }
- }
- else if (operations=='*')
- {
- result = N1 * N2;
- if (result % 2==0)
- {
- Console.WriteLine($"{N1} {operations} {N2} = {result} - even ");
- }
- else if (result%2==1)
- {
- Console.WriteLine($"{N1} {operations} {N2} = {result} - odd ");
- }
- }
- else if (operations=='/')
- {
- result = N1 / N2;
- if (N1==0 || N2==0)
- {
- Console.WriteLine($"Cannot divide {N1} by zero");
- }
- Console.WriteLine($"{N1} {operations} {N2} = {result:F2} ");
- }
- else if (operations=='%')
- {
- result = (N1 * 1.0) % N2; // nz
- if (N1==0 || N2==0)
- {
- Console.WriteLine($"Cannot divide {N1} by zero");
- }
- Console.WriteLine($"{N1} % {N2} = {result}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement