Display a Short Poem or Favorite Quote
Learning Objectives
Table of Contents
In this lesson, we will focus on understanding, learning, practicing, and applying the basics of displaying text in C#. By the end of the lesson, students will have a clear idea of how to print multiple lines of text using Console.WriteLine, allowing them to share a poem or favorite quote through code.
By the end of this lesson, students shall be able to:
- Understand how to use Console.WriteLine to display multiple lines of text.
- Learn how to format and organize text output in C#.
- Practice writing simple programs that print a poem or quote.
- Apply their knowledge to personalize output with their own chosen poem or inspirational quote.
Beginner-Friendly Source Code with Instructions
Follow these steps to create and run your program:
- Open Visual Studio Code and Open your folder (example: D:\2025-1_doe_bsis_1a).
- Open the terminal inside VS Code and create a new console project by typing:
dotnet new console -n poem_quote
- Go inside the folder: cd poem_quote
- Open the Program.cs file and replace the default code with the following:
using System; namespace PoemQuoteApp { class Program { static void Main(string[] args) { Console.WriteLine("Here is my favorite quote:"); Console.WriteLine(""The future belongs to those who believe in the beauty of their dreams.""); Console.WriteLine("- Eleanor Roosevelt"); Console.WriteLine(); // Adds a blank line Console.WriteLine("And here’s a short poem:"); Console.WriteLine("Roses are red,"); Console.WriteLine("Violets are blue,"); Console.WriteLine("Learning C#"); Console.WriteLine("Is fun with you!"); } } }
- Save the file and run the program with: dotnet run
Example Output
Here is my favorite quote: "The future belongs to those who believe in the beauty of their dreams." - Eleanor Roosevelt And here’s a short poem: Roses are red, Violets are blue, Learning C# Is fun with you!
Summary
In this lesson, you learned how to use Console.WriteLine to print multiple lines of text in C#. This skill allows you to display poems, quotes, or any text in a structured way. By understanding how text formatting works in console applications, you are one step closer to building more engaging programs.
Quiz
1. Which command is used to display text in C#?
A. Console.Input()
B. Console.ReadLine()
C. Console.WriteLine()
D. Console.Display()
2. What will Console.WriteLine() do after printing text?
A. Stays on the same line
B. Moves to the next line
C. Clears the screen
D. Ends the program
3. Which symbol is used to include quotation marks inside text output?
A. \\
B. //
C. \”
D. ”
4. What is the purpose of Console.WriteLine(); with nothing inside?
A. Causes an error
B. Prints a blank line
C. Prints NULL
D. Skips program execution
5. Why should programmers use Console.WriteLine multiple times for poems?
A. To make the program longer
B. To print each line separately
C. To avoid errors
D. To save memory
Exercises, Assessment, and Lab Exam
To strengthen your understanding, here are exercises and activities you can try. These will help you practice beyond the basic example and apply what you’ve learned to create your own outputs.
Exercises:
- Print your favorite motivational quote.
- Write a 4-line poem of your own and display it using Console.WriteLine.
- Add a blank line between each line of your poem.
- Print both a quote and a poem in the same program.
Assessment:
Submit a program that displays your chosen poem or quote with proper formatting.
Lab Exam:
During the lab exam, you will be asked to write a program that displays both a quote and a poem. Make sure your code runs without errors and the output is well formatted.
You may visit our Facebook page for more information, inquiries, and comments. Please subscribe also to our YouTube Channel to receive free capstone projects resources and computer programming tutorials.
Hire our team to do the project.