Advertisement
dimipan80

5.4ConditionalStatements_MultiplicationSign

Mar 21st, 2014
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.16 KB | None | 0 0
  1. using System;
  2.  
  3. class MultiplicationSign
  4. {
  5.     static void Main ()
  6.     {
  7.         Console.Write("Please, enter the First real number, A = ");
  8.         string numberStr = Console.ReadLine();
  9.         decimal numA = decimal.Parse(numberStr);
  10.         Console.Write("Enter the Second real number, B = ");
  11.         numberStr = Console.ReadLine();
  12.         decimal numB = decimal.Parse(numberStr);
  13.         Console.Write("Enter the Third real number, C = ");
  14.         numberStr = Console.ReadLine();
  15.         decimal numC = decimal.Parse(numberStr);
  16.  
  17.         char signNum;
  18.         if (numA != 0 && numB != 0 && numC != 0)
  19.         {
  20.             if ((numA > 0 && numB > 0 && numC > 0) || (numA > 0 && numB < 0 && numC < 0)
  21.                 || (numA < 0 && numB > 0 && numC < 0) || (numA < 0 && numB < 0 && numC > 0))
  22.             {
  23.                 signNum = '+';
  24.             }
  25.             else
  26.             {
  27.                 signNum = '-';
  28.             }
  29.         }
  30.         else
  31.         {
  32.             signNum = '0';
  33.         }
  34.         Console.WriteLine("The Sign of Multiplication of these 3 numbers is: SIGN = {0} !",
  35.             signNum);
  36.         Console.ReadLine();
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement