Fix validation in Lesson 2 Task 2

This commit is contained in:
Stanislav Mykhailenko 2023-03-20 02:36:26 +02:00
parent 0c9ebe46aa
commit 6548c0b5f0
GPG key ID: 1E95E66A9C9D6A36

View file

@ -21,14 +21,14 @@ int maximum;
while (true) while (true)
{ {
Console.Write("Enter minimum age: "); 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; break;
} }
while (true) while (true)
{ {
Console.Write("Enter maximum age: "); 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; break;
} }