Get Codex to build a simple business calculator
Three items at a ten per cent discount is a useful test. A blank that quietly becomes zero is a useful reason to test again.

What you'll make
a local pricing page with labelled inputs, a total and clear messages for invalid input, checked against answers you worked out yourself.
What you'll need
Codex in the ChatGPT desktop app (or the Codex CLI) through your work account, an empty practice folder, a web browser to open the finished HTML file, and a pricing rule you understand. About 45 minutes.
Example result.
Quantity 3, discount 10% → £32.40
Quantity 0, discount 10% → £0.00
Quantity blank → "Quantity required" (no total shown)
Discount 21% → "Discount must be 0–20%" (no total shown)
1. Define inputs, units and limits
Why not a spreadsheet? A formula works until someone types over it. A small page gives a colleague labelled inputs, validation they can’t break and one total, with the rule kept out of reach.
Name each input and its unit. Decide whether zero is valid, what a blank means and the allowed range. State the rounding and which charges are included, so the total doesn’t quietly acquire tax, delivery or a discount policy.
The practice rule: £12 per item. Quantity is a whole number from 0 to 1,000. Discount is a whole percentage from 0 to 20. Both are required. Tax and delivery are excluded. Write your expected answers now, before any code exists. The worked example has the full table.
Why this works: answers you worked out yourself are an independent check. Answers worked out after seeing the code are a second explanation of the same mistake.
What you should see: a one-paragraph rule and a short table of inputs and expected results.
2. Ask Codex for a plan
In the ChatGPT desktop app, open your practice folder, choose Codex and start a New chat. (With the CLI, run Codex from inside that folder.)
Plan a local fictional pricing calculator. Fixed unit price: £12. Quantity: whole number 0–1000. Discount: whole percentage 0–20. Total = quantity × 12 × (1 − discount/100). Both inputs are required. Blank is unknown, and zero quantity is valid. Exclude tax, delivery and other charges. Use exact pence arithmetic.
Propose separate HTML, CSS and JavaScript files and the steps to preview and check them locally. Use labelled, keyboard-operable controls and clear feedback. Invalid input must remove any previous total. No external services, saved inputs, dependencies, deleted files or publishing. Don't create any files yet.
Why this works: a plan you can read before anything is written is cheaper to correct than a finished page. Separate files keep the calculation easy to find.
What you should see: a short plan naming three new files, the validation for each input and how Codex will check the result.
3. Build it and compare with your answers
When the plan matches your rule, ask Codex to build it:
Build the reviewed plan in [agreed files]. Add a reset to quantity 3 and discount 10. Run the calculation checks, then open the local page and check input changes, invalid-result clearing, keyboard use and a narrow screen. Report what you ran, the results, and any check you couldn't run. Don't touch other files, commit, push or deploy.
[agreed files] are the filenames from the plan.
Open the HTML file in your browser. Try every row in your table. For this rule, exact pence are quantity × 12 × (100 − discount), so 3 at 10% is 3,240 pence, or £32.40. Then clear a field after a valid total: the old total must disappear. Try 21% and a quantity of 1.5. A number field’s minimum and maximum don’t replace the program’s own checks.
Tab through the controls and use them from the keyboard. Labels should be visible and the result should fit a narrow window. If you’d like to compare, the reference practice page behaves as the rule describes.
Why this works: Codex’s report says what it ran. Your browser shows what a colleague will see.
What you should see: every row in your table matching, and no stale total after an invalid input.
Check the result
- Every expected answer in your table appears exactly, in pounds and pence.
- A blank quantity shows a message, not £0.00.
- After an invalid input, the previous total is gone.
- Discount 21 and quantity 1.5 are rejected with a clear message.
The usual failure: the calculation is right and the page is wrong. A blank becomes zero, or the last valid total stays on screen after the input turns invalid. Spot it by clearing a field straight after a valid result.
The calculator fails this case: [inputs, expected and observed]. Check the input validation, calculation and result display. Fix the cause without changing the agreed rule or my expected answers. Rerun the normal, zero, blank, fractional and discount-limit checks, and the browser interaction. Report the results and any remaining gaps. Keep the job local.
[inputs, expected and observed] is the failing row, such as “quantity blank, expected ‘Quantity required’, saw £0.00”. Don’t move the discount limit to 21 because the program accepts it. The specification is the check.
Worked example: valid zero, invalid blank
Fictional example. The rule from step 1, with the expected answers:
| Quantity | Discount | Expected |
|---|---|---|
| 3 | 10% | £32.40 |
| 3 | 0% | £36.00 |
| 3 | 20% | £28.80 |
| 0 | 10% | £0.00 |
| blank | 10% | Quantity required, no total |
| 3 | 21% | Discount invalid, no total |
| 1.5 | 10% | Whole quantity required, no total |
The first build passed every calculation check in Codex’s report. In the browser, entering 3 at 10% showed £32.40. Clearing the quantity then showed £0.00.
- The failure. The page treated a blank as zero. Under this rule, zero items is a valid £0.00, but a blank supplies no quantity at all.
- The repair. The correction prompt with “quantity blank, expected ‘Quantity required’, saw £0.00” fixed the validation. The rerun showed the message and cleared the total.
- Why the report missed it. Codex tested the calculation function, which was right. The fault was in what the page displayed after an input changed.
Task kit for this job: Download (ZIP) · Reusable instructions
Go deeper
Optional training: change the rule deliberately
Your manager adds an extra 5% off for orders above 100 items. Don’t let Codex guess the detail. Agree it first: “above 100” means 101 or more, and the extra 5 points add to the entered discount. Then write new answers: 100 items at 10% is £1,080.00. 101 items at 10% is £1,030.20. 1,000 items at 10% is £10,200.00.
Update the agreed rule: for quantities above 100, add 5 percentage points to the entered discount. Keep every other rule. Update the validation and calculation together, then check these new cases against my answers: [new expected answers]. Report each result.
[new expected answers] is your three-row table. Notice that 101 items now costs less than 100. That’s the kind of thing the rule’s owner should see before customers do.
Optional training: separate the rule from the page
Ask for a calculation function that takes inputs and returns either an amount or a named invalid state. You can then test the rule without a browser, and test the page separately. Both matter: a function can pass while the page still shows yesterday’s result. If you use a screen reader, check that the result is announced when it changes.
Optional training: review the files before wider use
Before a colleague uses the page, read what Codex changed and where the files live. Understand the files Codex changed and check whether a website change is actually live cover both. A practice quote page isn’t an approved pricing system, however tidy it looks.