Advertisement
ada1711

Untitled

Aug 30th, 2024
10
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. static void Main(string[] args)
  2. {
  3. Greet();
  4. string[] preferences = GetPreferences();
  5. ChooseDish(preferences);
  6. }
  7.  
  8. static void Greet()
  9. {
  10. Console.WriteLine("Welcome to the meal selection program!");
  11. Console.WriteLine("We will help you decide what to eat for dinner today.");
  12. Console.WriteLine();
  13. }
  14.  
  15. static string[] GetPreferences()
  16. {
  17. Console.WriteLine("What dishes are you craving today? Please provide five dishes, separated by pressing enter.");
  18. string[] dishes = new string[5];
  19.  
  20. for (int i = 0; i < dishes.Length; i++)
  21. {
  22. dishes[i] = Console.ReadLine();
  23. }
  24. return dishes;
  25. }
  26.  
  27. static void ChooseDish(string[] preferences)
  28. {
  29. if (preferences.Length == 0)
  30. {
  31. Console.WriteLine("You did not provide any preferences.");
  32. }
  33. else
  34. {
  35. Random random = new Random();
  36. int index = random.Next(preferences.Length);
  37. string chosenDish = preferences[index];
  38.  
  39. Console.WriteLine($"Based on your preferences, we suggest you eat: {chosenDish} today.");
  40. }
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement