Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class ProductSignOf3NumsWithoutCalculation
- {
- static void Main()
- {
- //Telerik Academy
- //Write a program that shows the sign (+ or -) of the product of three real numbers without calculating it. Use a sequence of if statements.
- Console.Write("Please enter the first number:");
- decimal firstNum = decimal.Parse(Console.ReadLine());
- Console.Write("Please enter the second number:");
- decimal secondNum = decimal.Parse(Console.ReadLine());
- Console.Write("Please enter the third number:");
- decimal thirdNum = decimal.Parse(Console.ReadLine());
- if (firstNum == 0 || secondNum == 0 || thirdNum == 0)
- {
- Console.WriteLine("At least one of the entered numbers is zero so the product of the numbers will be 0!");
- }
- else if ((firstNum > 0 && secondNum > 0 && thirdNum > 0) || (firstNum > 0 && secondNum < 0 && thirdNum < 0) || (firstNum < 0 && secondNum < 0 && thirdNum > 0) || (firstNum < 0 && secondNum >0 && thirdNum < 0))
- {
- Console.WriteLine("The sign of the product of the three numbers: ({0}) * ({1}) * ({2}) is PLUS (+)!", firstNum, secondNum, thirdNum);
- }
- else
- {
- Console.WriteLine("The sign of the product of the three numbers: ({0}) * ({1}) * ({2}) is MINUS (-)!", firstNum, secondNum, thirdNum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement