Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- // Write a program that shows the sign (+ or -) of the product of three real numbers without calculating it. Use a sequence of if statements.
- class ShowsTheSign
- {
- static void Main()
- {
- float firstNum = float.Parse(Console.ReadLine());
- bool firstBoolNum = true;
- if (firstNum < 0)
- {
- firstBoolNum = false;
- }
- float secNum = float.Parse(Console.ReadLine());
- bool secBoolNum = true;
- if (secNum < 0)
- {
- secBoolNum = false;
- }
- float thirdNum = float.Parse(Console.ReadLine());
- bool thirdBoolNum = true;
- if (thirdNum < 0)
- {
- thirdBoolNum = false;
- }
- if ((firstBoolNum ^ secBoolNum ^ thirdBoolNum) == true)
- {
- Console.WriteLine("+");
- }
- else
- {
- Console.WriteLine("-");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement