skipter icon

C# Triangle Formations

skipter | PRO | 06/14/17 01:59:15 PM UTC | 0 ⭐ | 331 👁️ | Never ⏰ | []
C# |

1.3 KB

|

None

|

0 👍

/

0 👎

using System;
namespace DataBytes___Lab
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            int c = int.Parse(Console.ReadLine());
 
            Boolean isValid = true;
 
            if ((a + b > c) && (b + c > a) && (a + c > b))
            {
                Console.WriteLine("Triangle is valid.");
            }
            else
            {
                Console.WriteLine("Invalid Triangle.");
                return;
            }
            
            if ((a * a + b * b == c * c))
            {
                Console.WriteLine("Triangle has a right angle between sides a and b");
            }
            else if (b * b + c * c == a * a)
            {                
                Console.WriteLine("Triangle has a right angle between sides b and c");
            }
            else if (a * a + c * c == b * b)
            {               
                Console.WriteLine("Triangle has a right angle between sides a and c");
            }
            else if ((a + b > c) && (a + c > b) && (b + c > a))
            {               
                Console.WriteLine("Triangle has no right angles");
            } 
        }
    }
}

Comments