CalcBuilder Forum

Help making a calculator

User thiagobarreto 2020-01-21 14:43:10

I'm in doubt how to make a calculator.

need to convert a unit of weight (kg) into caloric weight, as follows:

if weight is <10kg = caloric weight is: weight x 1
if the weight is> 10kg and <20kg = (weight - 10) x 0.5 + 10
if weight is> 20 = (weight - 15) x 0.2 + 15


weight: ( form )
caloric weight: ( result )

result example 1:
Weight: 7kg
Caloric Weight : 7kg

result example 2:
Weight: 15kg
Caloric Weight : 12,5kg

result example 3:
Weight: 35kg
Caloric Weight : 18kg

Moonsoft support 2020-01-22 08:55:45

first you need to create your input fields, in this case weight, that you will receive at the code section as $weight. Then you can write your math at the code section and introduce the result into your variable (if you call it 'result', then you need to fill the $result variable, for ex):


For your case you also need to use 'if' clauses, so you can check the proper syntax here:

In order to build this kind of code

if($weight<10) {

And finally, you can write your result at the output section with



Hope this helps, regards


Create dynamic calculators

Buy now!

Perfect for small code changes or to correct any bug at your site

Buy now!