He built a profit calculator with AI. It kept getting the math wrong. Here’s the 3-prompt fix.

One evening, a developer stared at his AI-generated profit calculator and watched it confidently output wrong margins for every platform it touched.

Amazon: wrong. Etsy: wrong. eBay: wrong with zero hesitation.

He tried rephrasing the prompt. He tried being more specific. He tried asking nicely. The calculator kept smiling back at him with incorrect numbers and absolutely no shame about it.

The problem wasn’t the AI. It was the prompt.

🧮 Why this keeps happening

Real marketplace fees are messy. Etsy alone hits you with a 6.5% transaction fee + $0.20 listing fee + 3% payment processing. That’s already three separate calculations before you factor in shipping or offsite ads. Amazon’s referral fee shifts by product category, and it can swing from 6% to 45% depending on what you’re selling. Walmart and eBay each have their own tangled logic on top of that.

Ask AI to “build a side-by-side profit calculator for all four platforms” in one shot, and it will flatten all of that into something vague and confidently wrong. It might average the fees. It might guess. It might just pick a round number and commit to it like it’s been selling on these platforms for years.

The thing is, the AI isn’t bad at math. It’s bad at doing math AND building UI AND handling four different fee structures at the same time. That’s just too much. You wouldn’t ask a contractor to design the blueprints, pour the foundation, and wire the electricity simultaneously. Same idea here.

When you hand an AI too many jobs at once, it tries to do all of them and does none of them well. The output looks complete. The math is broken. And because the interface looks polished, you don’t catch the error until a real sale gives you a very real surprise.

📐 The fix: 3 prompts instead of 1

A builder in r/PromptEngineering shared the exact method he used to get this right. And honestly, it’s one of those things that feels obvious once you see it.

Step 1: Math only

Don’t ask for an app. Ask for the logic first.

Something like: “What is the exact formula for Etsy’s total fee on a $50 sale? List every component.”

Let the AI get the math right in complete isolation, before it touches a single line of HTML. This is the most important step in the whole process. A clean formula you can verify with a calculator is worth more than a beautiful interface built on garbage logic. Run the numbers yourself. If the AI says Etsy takes $4.13 on a $50 sale, do the math. If it checks out, move on. If it doesn’t, stay here until it does.

Step 2: UI logic only

Once the formulas check out, prompt for interactivity.

“Now build a tool that recalculates these formulas in real-time as the user types.”

At this point, the math is already locked in. The AI just needs to wire it to the inputs. Give it one job, and it does that job well. You can also specify things like layout, currency formatting, or which fields to show side by side. Keep this prompt focused on the interface, not the formulas. The formulas already exist. Don’t reopen that conversation.

Step 3: Edge cases only

AI will skip negative margins unless you specifically tell it not to. Every time.

“Add a visual highlight whenever net profit goes negative.”

One specific problem. One specific prompt. Done. You can use this same pattern for other edge cases too: free shipping thresholds, minimum fee floors, scenarios where the cost exceeds the sale price. Each one gets its own prompt. Each one gets solved cleanly without touching the work that came before it.

💡 Tips that actually help

  • Test each formula with a manual calculation before moving to the next step. Catch errors early, not after the UI is built.
  • Ask the AI to explain its fee calculation in plain English first. If the explanation is wrong, the code is wrong. The explanation is faster to check than the code.
  • For platforms with tiered or category-based fees, paste the official fee table directly into the prompt. Don’t trust the model to remember it correctly. Fee structures change, and AI training data has a cutoff date. The official page doesn’t.
  • If it hallucinates a fee structure, don’t retry the same prompt. Add the real numbers and try again. Repetition without new information usually produces the same mistake with slightly different wording.
  • Save your verified formulas somewhere. Once you’ve confirmed the math is right, you can reuse those formulas in future prompts without starting from scratch each time.

🚀 Use this on your next tool

This approach works for any math-heavy build, not just profit calculators. Tax tools, pricing engines, commission trackers, shipping cost estimators, discount calculators. Anything with nested logic that changes based on inputs will benefit from breaking the work into isolated steps.

The rule is pretty simple: separate the math from everything else. Get the logic right first. Then build on top of it. Then handle the edge cases. Three prompts, three focused jobs, one tool that actually works.

Most people get frustrated with AI-generated calculators and conclude the AI can’t do math. It can. It just can’t do everything at once. Give it one thing to be responsible for, and it will usually get it right.

What are you working on where this could apply?

How I prompted [Claude 3 / GPT-4] to build a complex cross-platform profit calculator (Handling multiple fee structures)
by u/Exact_Pen_8973 in PromptEngineering

Scroll to Top