Update Lesson 2 Task 1

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

View file

@ -11,16 +11,20 @@ for (int i = 0; i < 10; i++)
string? name; string? name;
float price; float price;
do while (true)
{ {
Console.Write($"Enter product {i + 1} name: "); Console.Write($"Enter product {i + 1} name: ");
name = Console.ReadLine(); name = Console.ReadLine();
} while (name == null); if (name != null)
break;
}
do while (true)
{ {
Console.Write($"Enter product {i + 1} price: "); Console.Write($"Enter product {i + 1} price: ");
} while (!float.TryParse(Console.ReadLine(), out price)); if (float.TryParse(Console.ReadLine(), out price))
break;
}
products.Add(new Product(name, price)); products.Add(new Product(name, price));
} }