Skip to content

fahmimee03/Calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

๐Ÿงฎ WPF Calculator

A modern calculator built with WPF and C#, featuring state machine architecture and full keyboard support.

โœจ Features

โœ… Basic Operations - Add, Subtract, Multiply, Divide
โœ… Operation Chaining - 5 + 3 + 2 = evaluates left-to-right
โœ… Large Numbers - Supports up to 9.2 quintillion (64-bit long)
๐ŸŽน Keyboard Support - Full keyboard + mouse input
๐Ÿ”„ State Machine - Prevents input bugs, clean UX flow
๐Ÿ›ก๏ธ Error Handling - Division by zero protection with MessageBox alerts
๐Ÿ“ฆ Modular Design - Separate UI and logic layers

๐Ÿš€ Quick Start

Prerequisites Visual Studio 2019+, .NET Framework 4.7.2+

Installation

git clone https://github.com/fahmimee03/wpf-calculator.git 
cd wpf-calculator
#Open Learning.sln in Visual Studio
#Press F5 to run

Example - Your Project Structure Section:

Project Structure

Learning/
โ”œโ”€โ”€ Calculator/ # WPF UI Project
โ”‚ โ”œโ”€โ”€ MainWindow.xaml # UI Layout
โ”‚ โ””โ”€โ”€ MainWindow.xaml.cs # UI Logic + State Machine
โ”‚
โ””โ”€โ”€ Learning/ # Class Library
----โ”œโ”€โ”€ BasicCalculator.cs # Core logic
----โ”œโ”€โ”€ ScientificCalculator.cs
----โ”œโ”€โ”€ ProgrammerCalculator.cs
----โ””โ”€โ”€ NumberConverter.cs # Binary/Hex/Octal

State Machine

EnteringFirstNumber โ†’ OperationSelected โ†’ EnteringSecondNumber โ†’ ResultDisplayed
โ†‘----------------------------------------------------------------------------------------โ†“
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ (New Calculation) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
Why? Prevents bugs like displaying "53" when user types 5 + 3 (should show "3").

Key Design Patterns

  • State Pattern - Manages calculator input flow
  • Inheritance - Scientific/Programmer extend BasicCalculator
  • Separation of Concerns - UI (WPF) โ†” Logic (DLL)
  • Event-Driven - Single event handler for multiple buttons

๐Ÿค Contributing

Contributions welcome! Areas for improvement:

๐Ÿ”ฌ Scientific mode UI (logic exists)
๐Ÿ’ป Programmer mode UI (Binary/Hex/Octal display)
๐Ÿ“œ Calculation history panel
๐Ÿ’พ Memory functions (M+, M-, MR, MC)
๐ŸŽจ Themes/skins support

Please:

Fork the repository
Create feature branch (git checkout -b feature/amazing)
Commit changes (git commit -m 'Add amazing feature')
Push to branch (git push origin feature/amazing)
Open Pull Request

๐Ÿ™ Acknowledgments

Design inspired by Windows Calculator
Built as part of C# WPF learning journey
State machine pattern from software engineering best practices

โญ Star this repo if you found it helpful! Made with โค๏ธ using C# and WPF

About

Basic calculator, base converter using C# and OOP.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages