I need to write a routine that calculates a value and applies a percentage. Both the value and the percentage must be requested. Perform this calculation using a function, returning the final value with the percentage applied.
I need to write a routine that calculates a value and applies a percentage. Both the value and the percentage must be requested. Perform this calculation using a function, returning the final value with the percentage applied.
I suppose the following code solves your problem.
function calcPorcentagem(valor, porcentagem: integer): double;
var
valorParcial: double;
begin
// Calcula o valor percentual
valorParcial := ((valor * porcentagem) / 100);
// Soma ao valor inicial a porcentagem desejada
calcPorcentagem := (valorParcial + valor);
end;