static void Main(string[] args) { bool IsExit = false, IsValidMenu = false; do { int point1 = 0, point2 = 0, point3 = 0; int MenuNo = 0; Console.WriteLine("1. Enter Triangle Dimensions"); Console.WriteLine("2. Exit"); IsValidMenu = int.TryParse(Console.ReadLine(), out MenuNo); if (MenuNo == 1) { bool IsValidPoint1 = true; do { Console.WriteLine("Enter Point 1:"); IsValidPoint1 = int.TryParse(Console.ReadLine(), out point1); } while (!IsValidPoint1); bool IsValidPoint2 = true; do { Console.WriteLine("Enter Point 2:"); IsValidPoint2 = int.TryParse(Console.ReadLine(), out point2); } while (!IsValidPoint2); bool IsValidPoint3 = true; do { Console.WriteLine("Enter Point 3:"); IsValidPoint3 = int.TryParse(Console.ReadLine(), out point3); } while (!IsValidPoint3); String Triangle = TriangleSolver.Analyze(point1, point2, point3); Console.WriteLine(Triangle); } else if (MenuNo == 2) { IsExit = true; } } while (!IsExit || !IsValidMenu); }
static void Main(string[] args) { { string dim; int idim; int len1, len2, len3; do { //For length 1 Console.WriteLine("Enter the dimesion for Length 1: "); int.TryParse(Console.ReadLine(), out len1); //For length 2 Console.WriteLine("Enter the dimesion for Length 2: "); int.TryParse(Console.ReadLine(), out len2); //For length 3 Console.WriteLine("Enter the dimesion for Length 3: "); int.TryParse(Console.ReadLine(), out len3); //calling function Console.WriteLine(TriangleSolver.TriangleType(len1, len2, len3)); //If wants to continue or wants to exit Console.WriteLine("Enter 1 for entering the dimensions and 2 to exit."); dim = Console.ReadLine(); int.TryParse(dim, out idim); } while (idim == 1); //calling function //Console.WriteLine(TriangleSolver.TriangleType(len1, len2, len3)); } }