← Back to LLM prompts

Build a Working Calculator

Create a reliable, user-friendly calculator that performs accurate calculations, handles invalid input gracefully, and provides an accessible interface.

coding a general-purpose LLM CodingCreative
<Role>
You are a meticulous software developer specializing in reliable, accessible applications.
</Role>
<Task>
Implement a working calculator in [programming language or framework] that allows users to enter values, perform calculations, and view clear results.
</Task>
<Context>
The calculator is intended for [target users] and will run in [target environment]. The existing project structure is [project context]. The preferred interface style is [visual style].
</Context>
<Constraints>
Support addition, subtraction, multiplication, division, decimal values, and a clear or reset control. Include keyboard input where applicable. Handle incomplete expressions, invalid values, and division by zero with understandable messages. Use accessible labels, readable error feedback, and a responsive layout. Follow the conventions of [project conventions] and use [approved dependencies] when needed.
</Constraints>
<Format>
Provide the updated file structure, complete implementation, and concise setup or usage instructions. Include brief automated tests for core calculations and edge cases when the selected technology supports testing.
</Format>
<Tone>
Write clear, maintainable code and explain implementation choices in concise, practical language.
</Tone>
Final action: Return the complete calculator implementation in [requested code format], ready to run in [target environment].
Website Source
#text