📖 Instructions#
The first thing we’ll do is greet the player. Right now, the program displays Hello world!. The goal of this lesson is to replace that with a proper welcome message for the game.
To do that, you need to understand two things: what a string is, and how to print text to the console.
A string is a data type used to represent text. In most languages, strings are written between quotes:
"Welcome to Odds and Evens!"To display a string in the console, you pass it to a built-in function designed for console output:
Console.WriteLine("Welcome to Odds and Evens!");When the program runs this line, it executes the function and the text appears in the console.
🎓 Learn More
✅ What to Do#
- Replace the
Hello world!message with a welcome message for the Odds and Evens game.
🎯 Expected Outcome#
Welcome to Odds and Evens!💡 Hints#
Hint 1
Find the line in your program file that currently prints Hello world!. That’s the only line you need to change.
Hint 2
The console output function displays whatever string you pass to it. Change the text inside the quotes.
🙈 Solution#
Tried, you must, before reveal the solution you may.
Program.csChanges
-- Console.WriteLine("Hello world!");
++ Console.WriteLine("Welcome to Odds and Evens!");
Program.csFinal
Console.WriteLine("Welcome to Odds and Evens!");
// Player chooses to play with odds or evens.
// Player enters a number between 1 and 2.
// Computer randomly generates a number between 1 and 2.
// Add the two numbers.
// Check if the sum is odd or even.
// Decide the round winner.
// Repeat rounds until one of the players wins two times.
// Announce the game winner.
// Ask the player to play again or quit.