0
0
C Sharp (C#)programming~15 mins

Console.WriteLine and Write methods in C Sharp (C#) - Mini Project: Build & Apply

Choose your learning style9 modes available
Using Console.WriteLine and Console.Write Methods
📖 Scenario: You are creating a simple console program that displays a greeting message and some information about a product. This will help you learn how to show text on the screen using Console.WriteLine and Console.Write methods.
🎯 Goal: Build a console program that first shows a greeting on one line, then shows product details on the same line using Console.Write, and finally moves to a new line with Console.WriteLine.
📋 What You'll Learn
Create a string variable called greeting with the value "Hello, welcome!".
Create a string variable called product with the value "Coffee".
Create a decimal variable called price with the value 4.99m.
Use Console.WriteLine to print the greeting variable.
Use Console.Write to print the product variable followed by a space.
Use Console.WriteLine to print the price variable formatted as currency.
💡 Why This Matters
🌍 Real World
Console output is used in many simple programs and tools to show messages, results, or instructions to users.
💼 Career
Understanding how to display information clearly on the console is a basic skill for developers working with command-line tools, debugging, or learning programming.
Progress0 / 4 steps
1
Create greeting and product variables
Create a string variable called greeting and set it to "Hello, welcome!". Also create a string variable called product and set it to "Coffee".
C Sharp (C#)
Need a hint?

Use string to create text variables and assign the exact values given.

2
Create price variable
Create a decimal variable called price and set it to 4.99m.
C Sharp (C#)
Need a hint?

Use decimal type and add m after the number for money values.

3
Print greeting using Console.WriteLine
Use Console.WriteLine to print the greeting variable.
C Sharp (C#)
Need a hint?

Use Console.WriteLine with the variable name inside the parentheses.

4
Print product and price using Console.Write and Console.WriteLine
Use Console.Write to print the product variable followed by a space. Then use Console.WriteLine to print the price variable formatted as currency using price.ToString("C").
C Sharp (C#)
Need a hint?

Use Console.Write to print without moving to a new line, then Console.WriteLine to print the price and move to the next line.