markdown
A lightweight, robust command-line calculator built with C++. This project focuses on clean user input handling and a sleek terminal interface.
- Smart UI: Uses ANSI escape codes (
\033[A\r) to overwrite input lines, keeping the terminal display clean and professional. - Robust Input Handling: Prevents crashes from invalid characters (like letters) using
std::cin.clear()andstd::numeric_limits. - Arithmetic Operations: Supports Addition (
+), Subtraction (-), Multiplication (*), and Division (/). - Safety First: Includes explicit checks for division-by-zero errors.
- Tutorial Mode: Built-in guidance to help new users understand the input format.
- A C++ compiler (GCC, Clang, or MSVC).
- A terminal that supports ANSI escape sequences (VS Code Terminal, Linux/Mac Terminal).
-
Clone the repository: bash git clone https://github.com
-
Compile the source code: bash g++ -o calculator main.cpp
-
Run the application: bash ./calculator
🛠️ Implementation Details The calculator uses a while(true) loop to maintain a continuous session. It validates input using a structured check: cpp if (!(cin >> num1 >> op >> num2)) { // Error recovery logic } Use code with caution.
This ensures the program remains stable even when receiving unexpected input formats. 📸 Preview text Calculation: 10 + 5 = 15 Calculation: 20 / 4 = 5 Error: Division by zero! Use code with caution.
Developed by Shawn-Yu-Dev