C# Console Lesson 3.3 — Simple Calculator

LessonsC# Console → Lesson 3.3
C# Console

Simple Calculator

“Add. Subtract. Multiply. Divide. A real tool you actually built.”

⏱ About 10 minutes 🛠 Visual Studio Community ⭐ Lesson 3 of 3

What you will have

A fully working console calculator — add, subtract, multiply and divide — that keeps running until you choose to quit.

It handles divide by zero gracefully. It loops so you can do multiple calculations without restarting.


Your prompt

Copy this. Paste it into your AI. Hit Enter.

📋 Your Prompt — Copy Everything Below
Write a C# console calculator application. The user chooses an operation: add, subtract, multiply, or divide. Then enters two numbers. The program displays the result. After showing the result, ask if they want to calculate again. If yes, loop back to the start. If no, say goodbye and exit. Handle divide by zero with a friendly error message. Keep the code clean with comments.
✅ Copied! Now paste it into your AI.

Video Walkthrough

Watch it built step by step.


What to do after

Follow these steps exactly.

1
Create a new Console App project
Visual Studio → Create a new project → Console App (C#) → name it Calculator → Create.
2
Delete starter code and paste yours in
Ctrl+A → Delete → Ctrl+V.
3
Press F5 and start calculating
Try all four operations. Then try dividing by zero on purpose.

🛠️ Didn’t work?

Don’t panic. Here’s exactly what to do:

1 Look at the error list at the bottom of Visual Studio
2 Copy the error message
3 Say: “This didn’t work. Here’s the error: [paste it]. Please fix it.”

Vibe Tweak

Add a fifth operation.

Find the menu that lists the four operations. Add a fifth option: Power — raise the first number to the power of the second.

Menu has
4 options
Add this
5. Power (x^y)

Extra Credit

Want to go further?

📋 Extra Credit Prompt
Add a calculation history to the calculator. Every time a result is shown, add it to a list. Add a sixth menu option called “Show History” that prints all previous calculations in order. Add a seventh option called “Clear History” that wipes the list.
✅ Copied!

Reflection

C# Console complete. Think about this.

“You built three C# programs — a greeter, a date calculator, and a working calculator. C# is used in AAA video games, enterprise software, and Windows apps. You just used the same language.”

C# Console Complete! What’s next?
Ready for WPF? Take your C# skills visual.
Real Windows apps with buttons, windows, and forms. Most sites skip WPF entirely. Not here.
Start WPF →
Greg the Vibe Coder · gregthevibecoder.com 18 lessons · No account required