Advertisement
skipter

C# Triangle Formations

Jun 14th, 2017
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.30 KB | None | 0 0
  1. using System;
  2. namespace DataBytes___Lab
  3. {
  4.     class Program
  5.     {
  6.         static void Main(string[] args)
  7.         {
  8.             int a = int.Parse(Console.ReadLine());
  9.             int b = int.Parse(Console.ReadLine());
  10.             int c = int.Parse(Console.ReadLine());
  11.  
  12.             Boolean isValid = true;
  13.  
  14.             if ((a + b > c) && (b + c > a) && (a + c > b))
  15.             {
  16.                 Console.WriteLine("Triangle is valid.");
  17.             }
  18.             else
  19.             {
  20.                 Console.WriteLine("Invalid Triangle.");
  21.                 return;
  22.             }
  23.            
  24.             if ((a * a + b * b == c * c))
  25.             {
  26.                 Console.WriteLine("Triangle has a right angle between sides a and b");
  27.             }
  28.             else if (b * b + c * c == a * a)
  29.             {                
  30.                 Console.WriteLine("Triangle has a right angle between sides b and c");
  31.             }
  32.             else if (a * a + c * c == b * b)
  33.             {              
  34.                 Console.WriteLine("Triangle has a right angle between sides a and c");
  35.             }
  36.             else if ((a + b > c) && (a + c > b) && (b + c > a))
  37.             {              
  38.                 Console.WriteLine("Triangle has no right angles");
  39.             }
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement