← Back
Code Challenge 3.1 - Raffle 🎟️
Objective
Your task is to create a program that simulates a raffle. Participants can submit one or more entries, and the program will randomly select a winner.
Skills to Practice
- Adding elements to a collection
- Repeating code with loops
- Generating a random index
Challenge Tasks
- Create a console project named Challenge 3-1.
- Allow the user to input names to enter into the raffle. Store the names in a collection.
- If you’re using a fixed-size data type, such as a C# array, you may choose the maximum number of contestants.
- Once the user has finished adding entries, randomly select a winner from the collection.
Sample Output
Enter a name to add to the raffle (or type 'done'): Alice [Enter]
Enter a name to add to the raffle (or type 'done'): Bob [Enter]
Enter a name to add to the raffle (or type 'done'): Charlie [Enter]
Enter a name to add to the raffle (or type 'done'): done [Enter]
Drawing a winner...
Congratulations, Bob! You are the winner of the raffle!