🧮 Professional Scientific Suite: Engineering-Grade Calculator

(C) Context

You are a Senior Software Engineer specializing in mathematical computing and front-end interface architecture. Your goal is to build a high-precision, professional-grade scientific calculator web application that rivals physical devices like the TI-84 or Casio FX series in both logic and usability.

(O) Objective

Develop a fully responsive, feature-rich scientific calculator using HTML5, CSS3, and JavaScript. The application must include:

  1. Core Math Engine: * Basic arithmetic with strict adherence to the Order of Operations (PEMDAS/BODMAS).
    • Advanced functions: Trigonometry ($sin, cos, tan$, and inverses), Logarithms ($\log, \ln$), Exponents ($x^y, e^x, 10^x$), and square roots.
    • Statistical functions (Mean, Sum, Standard Deviation).
    • A toggle switch for Degree/Radian modes.
  2. Memory & History:
    • Standard memory registers (M+, M-, MR, MC) with a visual indicator showing when data is stored.
    • A scrollable calculation history log that tracks previous expressions and results, with options to clear or persist data.
  3. Advanced UX/UI:
    • Responsive Layout: A dynamic UI that switches between a simplified "Standard" view for small screens and a "Scientific" expanded view for larger screens.
    • Keyboard Support: Mapping physical keys to calculator functions (e.g., * for multiply, Enter for equals, Backspace for delete).
    • Copy/Paste: Ability to copy results to the clipboard and paste external numeric strings into the display.
  4. Reliability & Customization:
    • Error Handling: Graceful management of division by zero, square roots of negatives (unless using complex numbers), and overflow, with user-friendly messages.
    • Theming: Three distinct UI modes: Classic (retro), Modern (minimalist), and High Contrast (accessibility).
    • Haptics/Audio: Optional button-press sound feedback with a volume slider.

(S) Style

  • Logic: Use a robust expression parser (like math.js or a custom Shunting-yard algorithm implementation) rather than eval() for security and precision.
  • Design: Use CSS Grid for the button layout to ensure perfect alignment. Use CSS variables for the themes to allow instant switching.
  • Purity: Focus on vanilla JavaScript for the core logic to ensure high performance and zero dependencies unless necessary for complex parsing.

(T) Tone

Technical, rigorous, and highly organized.

(A) Audience

Students, engineers, and developers who require a reliable, professional-grade calculation tool in their browser.

(R) Response Format

Provide the solution in organized code blocks:

  • index.html (Structure and Aria labels for accessibility).
  • styles.css (Grid layouts and theme definitions).
  • app.js (Math logic, event listeners, and state management).Include brief documentation on the keyboard mapping and how the expression parser handles nested parentheses.

Subscribe to AI Prompt Library-AI提示庫

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe