https://github.com/fizzymo/modular-c-calculator
C++ project demonstrating basic calculator functionality, input validation, and code organization across multiple files.
https://github.com/fizzymo/modular-c-calculator
Last synced: about 1 year ago
JSON representation
C++ project demonstrating basic calculator functionality, input validation, and code organization across multiple files.
- Host: GitHub
- URL: https://github.com/fizzymo/modular-c-calculator
- Owner: FizzyMo
- Created: 2024-07-31T09:05:43.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-08-16T20:52:57.000Z (almost 2 years ago)
- Last Synced: 2024-08-16T21:56:21.643Z (almost 2 years ago)
- Language: C++
- Homepage: https://youtu.be/W8NV80-eHzU
- Size: 11.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
C++ Calculator
### Description
This is a C++ calculator software that runs on the console. It provides a simple interface for conducting fundamental mathematical operations like addition, subtraction, multiplication, and division. The calculator is built to withstand a range of input circumstances, ensuring a smooth user experience through rigorous error management and input validation. It is a fantastic explanation of important programming principles including object-oriented design, string manipulation, and error handling in C++.
***
## Table of Contents
* [Features](#features)
* [Wiki](#wiki)
* [Steps To Run](#steps-to-run)
* [Error Handling](#error-handling)
* [Technologies](#technologies)
* [Project Structure](#project-structure)
* [Author](#author)
* [Contact](#contact)
***
### Features
- **Basic Arithmetic Operations:**
- Supports addition, subtraction, multiplication, and division.
- **Flexible Input:**
- Accepts both single-line equations (e.g., "6 + 3") and step-by-step input of operands and operators.
- **Robust Error Handling:**
- Prevents invalid input and calculations, including:
- Division by zero
- Incorrect number formats
- Empty or whitespace
- **Multiple Calculations:**
- Allows users to perform consecutive calculations in a single session.
- **Clear Screen Option:**
- Users can choose to clear the screen between calculations.
### Wiki
This project is thoroughly documented in the [Wiki](https://github.com/FizzyMo/Modular-C-Calculator/wiki), which provides detailed insights into the software development process, including problem analysis, design, implementation, and testing.
### Steps To Run
1. **Clone the repository:**
- Open your terminal or Git Bash.
- Navigate to the directory where you want to clone the repository.
- Use the following command to clone the repository:
``
git clone https://github.com/your-username/calculator.git ``
- This will download the project files to your local machine.
1. **Using Visual Studio 2022**
- Open Visual Studio 2022.
- Go to "Open" -> "Project or Solution"
- Navigate to the directory where you cloned the repository.
2. **Build the Project:**
- Press **Ctrl+Shift+B** or go to "Build" -> "Build Solution" to compile the project.
3. **Run the Project:**
- Press **F5** or go to "Debug" -> "Start Debugging" to run the calculator program.
4. **Use the Calculator:**
- The calculator will launch in a console window.
- Follow the on-screen prompts to enter equations or numbers and perform calculations.
### Error Handling
The calculator is built with extensive error handling to guide the user and prevent unexpected behavior:
- **Input Validation:**
- Ensures that only valid non-negative numbers, operators, and equation formats are accepted.
- **Division by Zero Prevention:**
- Catches attempts to divide by zero and displays an error message.
- **User-Friendly Messages:**
- Provides clear and informative messages to guide the user in case of incorrect input.
### Technologies
- **C++:**
- The core programming language used for implementing the calculator logic. This structure promotes code organization, readability, and reusability of components.
- **Standard Template Library (STL):**
- Used for string manipulation (`std::string`, `std::stringstream`), input/output (`std::cin`, `std::cout`), and exception handling (`std::exception`, `std::invalid_argument`).
- **Visual Studio 2022:**
- The IDE (Integrated Development Environment) used for creating, compiling, and running the project.
### Project Structure
The project is organized into multiple files:
- **`calculator.h`:**
- Contains the declaration of the `Calculator` class, outlining its member functions.
- **`calculator.cpp`:**
- Provides the implementation (definitions) for the member functions of the `Calculator` class, including the core calculator logic.
- **`main.cpp`:**
- Contains the `main()` function, which is the entry point of the program. It creates an instance of the `Calculator` class and starts the calculator's execution.
### Author
**Carisa Saenz-Videtto**
### Contact
carisasaenz@gmail.com