Build a Percentage Calculator for Discounts, Increases and Percent Change
A single HTML file that answers the four common percentage questions side by side, with live results and the worked formula shown under each answer.
You getone complete HTML file in a single code block, then 3 short ideas to extend it.
The prompt
Act as a senior front-end developer and UI designer who builds small, dependable everyday tools.
Build Percentwise, a single-page percentage calculator that answers the four questions people actually ask, shown side by side as four cards:
1. What is X% of Y?
2. X is what percent of Y?
3. Sale price or markup: a price with a percentage taken off or added on.
4. Percent change from an old value to a new value.
Rules:
- Each card reads as a plain sentence with small inline number inputs. Results update live as the user types, with no submit button and no form element. Prefill realistic sample numbers so every card shows an answer on first load.
- Under each result, show the worked formula with the user's numbers substituted. For example: 64 × (1 − 25 ÷ 100) = 48.
- Card 3 has a two-button Discount / Increase toggle using aria-pressed. It shows the final price and the amount saved or added.
- Card 4 colors increases green and decreases a burnt orange, and shows the absolute difference. Handle empty input, stray commas, $ and % signs, and division by zero with a friendly message instead of NaN.
- Use a responsive grid that runs from one column at 360px to four columns at 1280px. Use a warm off-white background, one teal accent, system fonts and a clear type scale. Add a subtle result flash that is disabled under prefers-reduced-motion. Results are announced through aria-live, and a Reset button restores the examples.
Output format: one complete HTML file in a single code block, then 3 short ideas to extend it.Example output
Tips and common edits
Why this works
- Naming all four questions and their formulas leaves the model nothing to guess, so every card computes correctly.
- Prefilled sample values and live updates mean the page shows real answers on first load, with no button to find.
- Explicit edge cases (empty input, symbols, divide by zero) stop the NaN and Infinity results simple calculators often show.
Paste into ChatGPT, Claude or Gemini. Save the returned code as percentwise.html and open it in any browser, or view it in the chat's preview or canvas panel. It works offline.
Common edits
- Swap the $ formatting for your currency (€, £, ₹) or add a tip-and-split card as a fifth question.
- Change the teal accent and orange/green colors to match your brand, or add a dark theme via prefers-color-scheme.
Prompt details
- By
- Prompts-GPT editors
- Published
Did this prompt work?
Keep exploring
More like this
Build a BMI and Daily Calorie Calculator with Metric and Imperial Units in HTML
A prompt that makes an AI build Steady Scale, a single-file BMI and calorie calculator using Mifflin-St Jeor, activity levels, unit switching and plain-language ranges.
Build a Countdown Timer to Any Date With a Confetti Finish in One HTML File
Get a polished single-file countdown page with a custom event title, a large days-hours-minutes-seconds display and a confetti-and-chime celebration at zero.
Build a HIIT and Tabata Interval Workout Timer in a Single HTML File
A self-contained interval timer with adjustable work, rest and rounds, color-coded phases, synthesized countdown beeps and a tap-anywhere pause, all in one HTML file.
Build a Keyboard-Friendly To-Do Checklist with Priorities and Filters in One HTML File
A ready-to-paste prompt that makes an AI build a single-file to-do checklist where you can add, reorder, prioritize, filter and export tasks as plain text, all with keyboard shortcuts.
Build a Live Word and Character Counter with Reading Time in One HTML File
A single-file text counter showing live words, characters, sentences, paragraphs, reading and speaking time, and color-coded progress bars for common post length limits.
Build a Loan and Mortgage Calculator with Amortization Table in One HTML File
Get a polished, offline loan and mortgage calculator that shows monthly payment, total interest, an SVG balance chart, extra-payment savings and a full amortization schedule.