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

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

One HTML file. Save it and open it in any browser.Open full screen

Example: Percentwise, a four-in-one percentage calculator.

Four cards answer the classic questions at once: X% of Y, X as a percent of Y, sale price or markup, and percent change. Type into any inline box and the answer, the plain-English summary and the worked formula update instantly. Try the Discount / Increase toggle on the price card, enter a lower new value in the change card to see it turn orange, and press Reset examples to start over.

Written by AI from this prompt. Your results will vary.

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 in Mini Apps & Tools