Doubts in Calculation of%

1

Would anyone know how to explain the following formula? I have 3 values: Valor_Vendido , Valor_Minimo_A_Ser_Vendido and %_Atingida .

Example:

I sold 500 reais and Valor_Minimo_A_Ser_Vendido was to be 1000 reais, so I hit 50% in %_atingida .

Do not need to give me a hand kissed the code in C #, I would just like to know the formula to do the same.

    
asked by anonymous 20.04.2017 / 19:51

3 answers

6

Rule of three. It's more of a mathematical question than a C # problem.

var percentual = (valorVendido * 100) / valorMinino;
    
20.04.2017 / 19:54
5

Decorating a formula is complicated, because in a few minutes we will surely forget it.

It is better to understand the mechanism, hence we will never forget how to calculate.

Assembly is very simple:

Question

 Se 1000 = 100%, 

    500 = quantos%

Let's build our equation

   1000     100
 _______ = _______

   500    quantos

Asked the question is only to solve the equation.

As it is a simple three-direct rule, we multiply the values in cross, that is, in X,

How many * 1000 = 500 * 100

How many = (500 * 100) / 1000

that would be quantos = (valorVendido * 100) / valorMinino;

How many = 50000/1000

How many = 50%

    
20.04.2017 / 21:24
2

Remember, a percentage is a ratio of two values (and therefore, one divided by the other) multiplied by 100. Using your example, you soon find out who should be divided by whom; there's only multiplying by 100. That goes for C # or any programming language.

    
20.04.2017 / 19:56