Advertisement
geniusvil

ConditionalStatements-T02.ShowSignOfProduct

Nov 8th, 2013
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. using System;
  2.  
  3. class ShowSignOfProductVersion2
  4. {
  5. static void Main()
  6. {
  7.  
  8. double n;
  9. int countPositive = 0;
  10. int countNegative = 0;
  11. for (int i = 1; i <= 3; i++)
  12. {
  13. do
  14. {
  15. Console.Write("n = ");
  16. }
  17. while (!double.TryParse(Console.ReadLine(), out n));
  18.  
  19. if (n > 0)
  20. {
  21. countPositive++;
  22. }
  23. else
  24. {
  25. countNegative++;
  26. }
  27. }
  28. if ((countNegative != 0))
  29. {
  30. if (countNegative % 2 == 0)
  31. {
  32. Console.WriteLine("+");
  33. }
  34. else
  35. {
  36. Console.WriteLine("-");
  37. }
  38. }
  39. else
  40. {
  41. Console.WriteLine("+");
  42. }
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement