📖 Instructions#
The player needs to choose between odds and evens. To keep things simple, we represent that choice with a number: 1 for odds, 2 for evens.
We already know how to print a message. Now we need to read what the player types back. To do that, we use a built-in function designed for exactly this:
Console.ReadLine();When the program reaches this line, it pauses and waits for the player to type something and press Enter. Once they do, the program continues. This is running a program in action — executing instructions one by one and responding to input as it arrives.
🧠 Recall
🎓 Learn More
✅ What to Do#
Print the message Choose 1 for Odds or 2 for Evens: and read the player’s input.
🎯 Expected Outcome#
Welcome to Odds and Evens!
Choose 1 for Odds or 2 for Evens:
1
The program pauses after printing the prompt. After you type 1 and press Enter, it finishes and exits.
💡 Hints#
Hint 1
Find the comment that marks where this step belongs. That’s where your new lines go.
Hint 2
You need two lines: one to print the prompt, and one to wait for what the player types.
Hint 3
You already know how to print. Reading input uses a function from the same class you’ve been using for output.
⚠️ Common Mistakes#
Calling ReadLine without parentheses
Writing Console.ReadLine instead of Console.ReadLine() causes a compile error. The parentheses are required — they’re what actually calls the function.
Printing the prompt after reading input
If you write Console.ReadLine() before Console.WriteLine(...), the program waits for input before the player has seen any prompt. Always print first, then read.
Mixing up WriteLine and ReadLine
Console.WriteLine prints to the screen. Console.ReadLine reads from the keyboard. They’re easy to swap by accident. If the program skips the pause entirely, check which one you used where.
🙈 Solution#
Tried, you must, before reveal the solution you may.
Program.csChanges
// Player chooses to play with odds or evens.
+ Console.WriteLine("Choose 1 for Odds or 2 for Evens:");
+ Console.ReadLine();
Program.csFinal
Console.WriteLine("Welcome to Odds and Evens!");
// Player chooses to play with odds or evens.
Console.WriteLine("Choose 1 for Odds or 2 for Evens:");
Console.ReadLine();
(...)