ForHosting KIT · Math

CP SP MP calculator

Work through classic profit-and-loss questions: with a cost of 100, a marked price of 150 and a 10% discount, the selling price is 135 and the profit is 35, or 35% on cost. Handy for homework and exam practice. Free in your browser.

  • Free
  • Runs in your browser
  • No sign-up
  • Your data stays on your device
Use it from WebAPIEmailTelegramApp soon
If you enter
Calculation mode
From cost and marked price
Cost price
100
Marked price
150
Discount (%)
10
You get
Selling price
135
Discount amount
15
Profit
35
Profit on cost price (%)
35

School arithmetic for cost price (CP), selling price (SP) and marked price (MP) with discount on MP and profit on CP. Free, deterministic, and private in your browser. No account required.

Three prices on the same item

Profit-and-loss problems describe one item with three prices. The cost price is what the seller paid for it. The marked price, also called the list or ticket price, is the figure printed on the label before any discount. The selling price is what the buyer actually pays once the discount on the marked price is applied. The gap between marked and selling price is the discount amount, and the gap between selling price and cost is the profit. Keeping the three apart is most of the work, because each percentage in a problem refers to a different one of them.

How the figures are worked out, and the usual slips

The discount is always taken on the marked price: a marked price of 150 with 10% off sells for 135, a discount of 15. The profit percentage is always measured on the cost: selling for 135 something that cost 100 gives a profit of 35, which is 35%. The classic slip is to work out the profit percentage on the selling price, or the discount on the cost. A sale below cost simply shows a negative profit, which is a loss, and a cost of zero leaves the percentage empty instead of dividing by zero. Negative prices are refused.

How cost, selling and marked prices relate

Classical quantitative aptitude problems define three prices on the same item. Cost price (CP) is what the seller paid. Marked price (MP), also called list or ticket price, is the figure printed before any discount.

Selling price (SP) is what the buyer actually pays after a discount on the marked price. Discount amount is MP minus SP. Every input that participates in arithmetic must be a finite number; negative prices are rejected.

Edge cases, limits and classroom use

Rejects negative cost, marked, or selling prices with an explicit message. Division by zero cost yields null profit percent rather than Infinity or NaN. Integrators should treat match substrings on error messages as part of the public contract.

The implementation never calls the network and never stores inputs, which keeps tier A free and private for exam hall use on shared devices.

Homework and exams

Check classic profit-and-loss problems with stable, reproducible answers for CP, SP and MP.

Automation scripts

Call the same pure function from scripts without installing a spreadsheet or computer algebra system.

Is this CP SP MP calculator free?

Yes. Tier A runs entirely in your browser without an account or network call.

What is the difference between MP and SP?

Marked price is the list or ticket price before discount; selling price is what the buyer pays after discount.

Can profit percent be null?

Yes. When cost price is exactly zero the tool returns null for profit percent instead of Infinity.

How do I find the selling price after a discount?

Take the discount off the marked price: the selling price is the marked price times one minus the discount over 100. The discount amount is simply the marked price minus the selling price.

How is the profit percentage calculated?

Subtract the cost from the selling price to get the profit, then divide that profit by the cost and multiply by 100. The percentage is always measured on the cost, never on the selling price.

What if I only know the cost and the selling price?

Choose the option for cost and selling price. You get the profit and the profit percentage on cost without any marked price being invented, which is what most textbook profit-and-loss questions ask for.

Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.

POSThttps://api.kit.forhosting.com/math/cp-sp-mp

Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.

curl -X POST https://api.kit.forhosting.com/math/cp-sp-mp \
  -H "Authorization: Bearer $KIT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"mode":"from_cp_mp","cp":1}'
{
  "mode": "from_cp_mp",
  "cp": 1
}
{
  "task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
  "type": "math.cp_sp_mp",
  "status": "queued",
  "_links": {
    "result": "/tasks/tsk_…/result"
  }
}

The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.

Per request$0.002

Published price — no tokens, no invented credits. A failed task is never charged.

HTTPCodeMeaning
401unauthorizedMissing or invalid API key.
402insufficient_balanceYour balance doesn't cover the task price.
404unknown_typeThat task type doesn't exist.
429rate_limitedToo many requests. Use the webhook instead of polling.

How cost, selling and marked prices relate

In the first mode, from_cp_mp, you supply cost, marked price and an optional discount percent on MP; the pure function multiplies MP by one minus discount over one hundred to obtain SP, then profit equals SP minus CP and profit percent on cost is profit divided by CP times one hundred when CP is not zero. In the second mode, from_cp_sp, you supply only cost and selling price; profit and profit percent on cost are returned without inventing a marked price. When cost is exactly zero the profit percent field is null rather than Infinity so clients never see a non-JSON number. Extremely large intermediate values that overflow IEEE-754 become a clear out-of-range error. Wrong types and missing required fields surface as invalid_input with stable English match substrings for the harness.

Inputs, modes and outputs

Profit can be negative when selling below cost, which correctly models a loss without a separate error path. Required fields must be present and correctly typed; optional fields use documented defaults. Choose mode from_cp_mp when you know cost and marked price and optionally the discount percent on the marked price; leave discount_pct empty or zero for no discount so selling price equals marked price. Choose mode from_cp_sp when the problem states cost and selling price only and you need profit figures. The success payload always includes mode, the prices you provided, and the computed fields named in the output contract so UI bindings never guess. Discount and discount_pct appear in from_cp_mp results; from_cp_sp omits them because no marked price was given.

Edge cases, limits and classroom use

Empty mode strings fall back to from_cp_mp; unknown mode names raise invalid_input. Contradictory combinations such as non-numeric strings after JSON parse fail early before any arithmetic. Extremely large intermediate products that leave the finite IEEE-754 range become an out-of-range error rather than silent null fields.

Teaching demos

Show worked examples with golden fixtures that match the free widget and the API path.

Which modes are supported?

from_cp_mp uses cost, marked price and optional discount; from_cp_sp uses cost and selling price only.

Who authors this capacity?

samurai on the ForHosting KIT workshop; the pure function is deterministic and covered by golden examples.

Read the full KIT documentation →