Advertisement
AnitaN

05.ConditionalStatementsHomework/04.MultiplicationSign

Mar 29th, 2014
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.85 KB | None | 0 0
  1. //Problem 4.Multiplication Sign
  2. //Write a program that shows the sign (+, - or 0) of the product of three real numbers, without calculating it. Use a sequence of if operators.
  3.  
  4. using System;
  5.  
  6. class MultiplicationSign
  7. {
  8.     static void Main()
  9.     {
  10.         Console.Write("Please, enter a:");
  11.         double a = double.Parse(Console.ReadLine());
  12.         Console.Write("Please, enter b:");
  13.         double b = double.Parse(Console.ReadLine());
  14.         Console.Write("Please, enter c:");
  15.         double c = double.Parse(Console.ReadLine());
  16.  
  17.         double result = a * b * c;
  18.  
  19.         if (result > 0)
  20.         {
  21.             Console.WriteLine("Result: +");
  22.         }
  23.         else if (result < 0)
  24.         {
  25.             Console.WriteLine("Result: -");
  26.         }
  27.         else
  28.         {
  29.             Console.WriteLine("Result: 0");
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement