While Loop: Usage and Examples
Here is the prompt to create the program
Prompt:
"Write a Python program that demonstrates the use of while loops and for loops for a small business simulation called 'Frank's Fruits.' The program should:
- Start by asking the user to stock the fruit stand with three types of fruits: Apples, Bananas, and Oranges. The user should input how many of each fruit are available, ensuring only non-negative integers are accepted.
- Ask if the user wants to open the fruit stand for the day. If the user says "yes," allow them to begin selling fruits. If the user says "no," display a message to "Have a good evening!" and stop the program.
- During the sales process:
- Display the current inventory of fruits.
- Prompt the user to input which fruit a customer wants to buy and how many they would like to purchase.
- Ensure the stand has enough stock to fulfill the order. If there isn't enough, notify the user and prompt them again.
- Deduct the sold amount from the inventory and display an updated stock.
- If the inventory for all fruits reaches 0:
- Display a message that "You have sold all the fruit!"
- Prompt the user to choose whether to restock the fruit stand or close for the day.
- If the user chooses to restock, ask how many of each fruit to add to the inventory and continue operations.
- If the user chooses not to restock, display a closing message and stop the program.
- Include robust input validation to ensure only valid responses are accepted (e.g., non-negative integers for stock and quantity).
The program should demonstrate clear, structured use of loops and conditionals for educational purposes."