Update Lesson 2 Task 2

This commit is contained in:
Stanislav Mykhailenko 2023-03-19 14:13:44 +02:00
parent 722437f3f7
commit a60bfaf1cd
GPG key ID: 1E95E66A9C9D6A36

View file

@ -16,16 +16,19 @@ List<Person> people = new List<Person>()
int minimum; int minimum;
int maximum; int maximum;
do while (true)
{ {
Console.Write("Enter minimum age: "); Console.Write($"Enter minimum age: ");
} while (!int.TryParse(Console.ReadLine(), out minimum) || minimum < 0 || minimum > 130); if (int.TryParse(Console.ReadLine(), out minimum) || minimum >= 0 || minimum <= 130)
break;
}
do while (true)
{ {
Console.Write("Enter maximum age: "); Console.Write($"Enter maximum age: ");
userInput = Console.ReadLine(); if (int.TryParse(Console.ReadLine(), out maximum) || maximum >= minimum || maximum <= 130)
} while (!int.TryParse(Console.ReadLine(), out maximum) || maximum < minimum || maximum > 130); break;
}
var selected = from person in people where person.Age >= minimum && person.Age <= maximum select person; var selected = from person in people where person.Age >= minimum && person.Age <= maximum select person;