Skip to content

Add scientific calculator operations and dark/light theme toggle - #25

Draft
haslam93 with Copilot wants to merge 2 commits into
mainfrom
copilot/turn-calculator-into-scientific
Draft

Add scientific calculator operations and dark/light theme toggle#25
haslam93 with Copilot wants to merge 2 commits into
mainfrom
copilot/turn-calculator-into-scientific

Conversation

Copilot AI commented Jan 8, 2026

Copy link
Copy Markdown
Contributor

Extends basic arithmetic calculator with scientific operations (sin, cos, tan, sqrt, log, power) and implements dark/light theme switching.

Backend Changes

  • Added 6 scientific operations to api/controller.js
  • Implemented single-operand operation handling (sin/cos/tan/sqrt/log don't require operand2)
  • Validated operation types before parsing operands
var singleOperandOps = ['sin', 'cos', 'tan', 'sqrt', 'log'];
var requiresTwoOperands = singleOperandOps.indexOf(req.query.operation) === -1;

if (requiresTwoOperands) {
  // validate and use operand2
  res.json({ result: operation(req.query.operand1, req.query.operand2) });
} else {
  res.json({ result: operation(req.query.operand1) });
}

Frontend Changes

  • Added 6 scientific function buttons in purple (#6f42c1) to distinguish from arithmetic operators
  • Implemented scientificOperation() for immediate single-operand calculations
  • Added theme toggle button (🌙/☀️) with toggleTheme() function
  • CSS variables enable smooth theme switching via .light-theme/.dark-theme body classes

Testing

Added 8 tests covering all scientific operations. All 32 tests pass.

Screenshots

Before:
Before

After - Light Mode:
Light Mode

After - Dark Mode:
Dark Mode

Original prompt

This section details on the original issue you should resolve

<issue_title>Jan2026- Turn this calculator into a scientific calculator</issue_title>
<issue_description>Summary:

Turn this calculator into a scientific calculator and add dark and light mode.

Acceptance Criteria:

  • Screenshots of before and after.
  • Calculator has scientific operations now like sin and cos.
  • The calculator UI is clean and modern
  • The operation buttons all work
  • A toggle to switch between dark and light theme.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: haslam93 <36418598+haslam93@users.noreply.github.com>
Copilot AI changed the title [WIP] Convert calculator to scientific calculator with themes Add scientific calculator operations and dark/light theme toggle Jan 8, 2026
Copilot AI requested a review from haslam93 January 8, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Jan2026- Turn this calculator into a scientific calculator

2 participants