Skip to content

About

SEN 214 calculator assignmment

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

SEN 214 Calculator

A scientific calculator Android app built with Kotlin and Jetpack Compose, covering basic arithmetic plus a full set of bonus scientific/mathematical features.


Features

Core (Basic Calculator)

  • Addition, subtraction, multiplication, division
  • Percentage, sign toggle, decimal input
  • Division-by-zero handled gracefully (shows "Error", no crash)

Bonus: Scientific Calculator

  • Trigonometric functions: sin, cos, tan and their inverses (sin⁻¹, cos⁻¹, tan⁻¹)
  • Hyperbolic functions: sinh, cosh, tanh
  • DEG / RAD toggle for angle mode
  • Logarithms: log (base 10), ln (natural log)
  • Powers & roots: x², √, xʸ
  • Other functions: 1/x, n! (factorial), constants π and e
  • Supports entering a function either before or after the number (e.g. both sin → 90 and 90 → sin work)

Bonus: Matrix Calculator

  • Supports matrix sizes from 2×2 up to 4×4
  • Operations: Addition, Subtraction, Multiplication, Determinant, Inverse, Transpose
  • Grid-style input for entering matrix values directly
  • Invalid operations (e.g. inverting a singular matrix, multiplying mismatched sizes) show a clear error instead of crashing

Bonus: Statistics & Combinatorics

  • Enter any dataset (comma-separated numbers) to compute:
    • Mean, Median, Mode, Range
    • Sample Variance, Sample Standard Deviation
  • Permutations (nPr) and Combinations (nCr) calculator with input validation

Design

  • Full dark / light theme toggle
  • Color-coded buttons (operators, functions, numbers, equals) for visual clarity
  • Built entirely with Jetpack Compose (modern, declarative Android UI)

Architecture

The app is split into a logic layer and a UI layer, so the math itself can be reasoned about (and tested) independently of the Android UI:

app/src/main/java/com/example/sencalculator/
├── MainActivity.kt              → Hosts the app, mode switcher (tabs), theme toggle
├── logic/
│   ├── CalculatorEngine.kt      → Basic arithmetic + scientific functions
│   ├── MatrixOps.kt             → Matrix add/subtract/multiply/determinant/inverse/transpose
│   └── StatsOps.kt              → Mean/median/mode/variance/stddev + nPr/nCr
└── ui/
    ├── BasicCalculatorScreen.kt
    ├── ScientificScreen.kt
    ├── MatrixScreen.kt
    ├── StatsScreen.kt
    └── theme/                   → Compose theme, colors, dark/light support

Key design choices:

  • All math functions in the logic layer return null on invalid input (e.g. divide by zero, square root of a negative number, inverse of a singular matrix) instead of throwing exceptions — the UI checks for null and shows a friendly error message.
  • The four calculator modes (Basic, Scientific, Matrix, Stats) are separate, independently testable Compose screens, switched via a tab bar in MainActivity.kt.

Screenshots

Basic Scientific
Basic Scientific
Matrix Statistics
Matrix Statistics

How to Build & Run

  1. Clone this repository:
    git clone https://github.com/LightX5/SEN-Calculator.git
  2. Open the project in Android Studio
  3. Run on an emulator or physical device via the Run button

A pre-built debug APK is also available in the /releases folder of this repo — download app-debug.apk and install it directly on an Android device (you may need to allow "install from unknown sources").


Tech Stack

  • Language: Kotlin
  • UI Toolkit: Jetpack Compose (Material 3)
  • Min SDK: API 24 (Android 7.0)
  • Architecture: Logic layer separated from UI (Compose screens + pure Kotlin math engine)

About

SEN 214 calculator assignmment

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages