From 6548c0b5f005df303b7d01108fec8d2bd6b89276 Mon Sep 17 00:00:00 2001 From: Stanislav Mykhailenko Date: Mon, 20 Mar 2023 02:36:26 +0200 Subject: [PATCH] Fix validation in Lesson 2 Task 2 --- Lesson_2/Task_2/Program.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lesson_2/Task_2/Program.cs b/Lesson_2/Task_2/Program.cs index febdcbc..c575e00 100644 --- a/Lesson_2/Task_2/Program.cs +++ b/Lesson_2/Task_2/Program.cs @@ -21,14 +21,14 @@ int maximum; while (true) { Console.Write("Enter minimum age: "); - if (int.TryParse(Console.ReadLine(), out minimum) || minimum >= 0 || minimum <= 130) + if (int.TryParse(Console.ReadLine(), out minimum) && minimum >= 0 && minimum <= 130) break; } while (true) { Console.Write("Enter maximum age: "); - if (int.TryParse(Console.ReadLine(), out maximum) || maximum >= minimum || maximum <= 130) + if (int.TryParse(Console.ReadLine(), out maximum) && maximum >= minimum && maximum <= 130) break; }