Forum


Calc Builder Support

Calc Builder support
Forums
No se permite escribir sin estar logado. Por favor, login

Help making a calculator 21.01.2020 14:43

Hello
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

form:

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

Re: Help making a calculator 22.01.2020 08:55

Hello,
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):

$result=$weight*5;

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

https://www.php.net/manual/en/control-structures.if.php

In order to build this kind of code

if($weight<10) {
$result=......;
}
if(.....condition...){
.....
}

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

##result##

tag.

Hope this helps, regards
Moonsoft Team
www.moonsoft.es
Are you satisfied with our products/services/support?
Please help us to keep improving, add a review at  joomla extensions site and  magento connect

Lo que nuestros clientes opinan de nosotros