Skip to content

Calculator — implement UI, operations, and keyboard support #161

@venisha-kalola

Description

@venisha-kalola

Project slug (e.g., snake, todo)

calculator

Summary

Build the calculator MVP using vanilla JS. Provide a display, a button grid, click handlers, and full keyboard support.

Details / Acceptance criteria

Acceptance Criteria:

  • Supports +, −, ×, ÷, =, ., AC (clear), CE/backspace, +/- (sign), %.
  • Prevents multiple decimals in a number.
  • Gracefully handles divide-by-zero.
  • Reasonable float rounding (e.g., 10–12 significant digits).
  • Keys 0–9, + - * / . Enter/Return, Escape (AC), Backspace (CE) work.
  • Responsive layout; display truncates/scrolls without breaking.

Files:

  • projects/calculator/index.html
  • projects/calculator/styles.css
  • projects/calculator/main.js

Tasks:

  • Build display + grid layout.
  • Wire button clicks and keyboard events.
  • Implement operation state machine (current, previous, operator).
  • Add formatting/rounding helpers.
  • Add ARIA labels and focus styles.

Scope

  • UI changes
  • Logic changes
  • Accessibility
  • Tests (manual)

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions