Skip to content

Simple Calculator is a C# console application built to practice programming fundamentals such as input handling, control flow, modularization, and code organization.

Notifications You must be signed in to change notification settings

tarsilafritz/cli-simple-calculator

Repository files navigation

🧮 Simple CLI Calculator

A simple command-line calculator built in C# for practicing basic programming concepts, clean code organization, and modular design.
This project supports multiple operations and includes input validation and reusable helper utilities.


🚀 Features

  • Addition
  • Subtraction
  • ✖️ Multiplication
  • Division (with division-by-zero validation)
  • 🔁 Option to continue the current operation or return to the main menu
  • 🧰 Reusable utility classes for input handling and menu navigation
  • 🎨 Clean and organized console layout for better readability

🧩 Project Structure

SimpleCalculator/
├── Program.cs # Main menu and program loop
├── Operations/ # All math operations
│ ├── Addition.cs
│ ├── Subtraction.cs
│ ├── Multiplication.cs
│ └── Division.cs
└── Utils/ # Shared helper classes
  ├── InputReader.cs
  └── MenuHelper.cs

🛠️ Technologies Used

  • Language: C#
  • Runtime: .NET SDK (version 8.0 or later recommended)
  • Editor: Visual Studio Code

⚙️ How to Run

  1. Clone the repository
    git clone https://github.com/tarsilafritz/cli-simple-calculator.git
    cd cli-simple-calculator
  2. Build the project
     dotnet build
  3. Run the calculator
     dotnet run
    

🧠 Example Usage

Hello, welcome to the calculator program!

=== Menu of operations: ===
1. Addition
2. Subtraction
3. Multiplication
4. Division
5. Exit
Please select an operation (1-5): 4


=====================================================================

4. Division
Inform the first value: 12
Inform the second value: 0
❌ You cannot divide by zero!
Please enter a non-zero divisor: 4

Do you want to add another value to the calculation? (Y/N): Y
Inform the next value: 2

Do you want to add another value to the calculation? (Y/N): N

The final result is: 1.5

Would you like to:
  [C] Continue Division
  [M] Return to main menu
Choose an option (C/M): C


=====================================================================

4. Division
Inform the first value: 100
Inform the second value: 25

Do you want to add another value to the calculation? (Y/N): N

The final result is: 4

Would you like to:
  [C] Continue Division
  [M] Return to main menu
Choose an option (C/M): M


=====================================================================

=== Menu of operations: ===
1. Addition
2. Subtraction
3. Multiplication
4. Division
5. Exit
Please select an operation (1-5): 5

Thanks for using our calculator program!

🌱 Future Improvements

  • Support for power, square root, and percentage
  • Add history tracking for previous results
  • Implement unit tests
  • Improve menu visuals with color and better formatting

👨‍💻 Created by @tarsilafritz

About

Simple Calculator is a C# console application built to practice programming fundamentals such as input handling, control flow, modularization, and code organization.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages