Advertisement
soxa

ShowsTheSign

Nov 16th, 2013
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | None | 0 0
  1. using System;
  2. // Write a program that shows the sign (+ or -) of the product of three real numbers without calculating it. Use a sequence of if statements.
  3.  
  4. class ShowsTheSign
  5. {
  6.     static void Main()
  7.     {
  8.         float firstNum = float.Parse(Console.ReadLine());
  9.         bool firstBoolNum = true;
  10.         if (firstNum < 0)
  11.         {
  12.             firstBoolNum = false;
  13.         }
  14.        
  15.         float secNum = float.Parse(Console.ReadLine());
  16.         bool secBoolNum = true;
  17.         if (secNum < 0)
  18.         {
  19.             secBoolNum = false;
  20.         }
  21.  
  22.         float thirdNum = float.Parse(Console.ReadLine());
  23.         bool thirdBoolNum = true;
  24.         if (thirdNum < 0)
  25.         {
  26.             thirdBoolNum = false;
  27.         }
  28.  
  29.         if ((firstBoolNum ^ secBoolNum ^ thirdBoolNum) == true)
  30.         {
  31.             Console.WriteLine("+");
  32.         }
  33.         else
  34.         {
  35.             Console.WriteLine("-");
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement