Advertisement
remote87

Sign of product

Sep 2nd, 2015
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.22 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading;
  6. using System.Globalization;
  7.  
  8. namespace _02.SignOfProduct
  9. {
  10.     class SignOfProduct
  11.     {
  12.         static void Main()
  13.         {
  14.             System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
  15.            
  16.             Console.Write("Enter first number: ");
  17.             double a = double.Parse(Console.ReadLine());
  18.             Console.Write("Enter second number: ");
  19.             double b = double.Parse(Console.ReadLine());
  20.             Console.Write("Enter third number: ");
  21.             double c = double.Parse(Console.ReadLine());
  22.  
  23.             int counter = 0;
  24.             if (Math.Sign(a) == 1)
  25.             {
  26.                 counter++;
  27.             }
  28.             if(Math.Sign(b) == 1)
  29.             {
  30.                 counter++;
  31.             }
  32.             if (Math.Sign(c) == 1)
  33.             {
  34.                 counter++;
  35.             }
  36.             if (counter % 2 == 0)
  37.             {
  38.                 Console.WriteLine("Negative");
  39.             }
  40.             else
  41.             {
  42.                 Console.WriteLine("Positive.");
  43.             }                
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement