06

RPN Calculator

A desktop Reverse Polish Notation calculator in C# with Avalonia UI. It has stack operations, keyboard input, a graph view and separate core, logic and test projects.

Language
C#
Year
2025
Team
Solo
Stack
  • C#
  • .NET 8
  • Avalonia
  • xUnit
RpnCalcApp · RpnCalc.Test
RpnCalc.Logic
RpnCalc.Core
  • .NET 8
  • Avalonia 11
  • xUnit

Features

  • Push numbers and calculate with +, −, × and ÷ on a stack of up to five values.
  • Swap the top values, clear the stack or remove the last digit.
  • Full keyboard control, including the number pad.
  • Errors such as too few values, a full stack or division by zero are shown in place.
  • Graph mode: the stack becomes the coefficients of a polynomial, plotted from −10 to 10.

How it's built

C# on .NET 8 with Avalonia UI and its dark Fluent theme. The solution has four projects: Core with the calculator interface and exceptions, Logic with the stack calculator and the function evaluator, the app, and xUnit tests.

The interface is built in C# code instead of XAML. Keys are mapped to the same handlers as the buttons, so mouse and keyboard behave the same.

For the graph, the stack is read as the coefficients of c₀ + c₁x + c₂x² + …, evaluated in steps of 0.01 and drawn as line segments on an Avalonia canvas with axes and tick marks.