Created
April 20, 2019 13:59
-
-
Save CristianoRC/e2bbdf5f6e416581ac5c6a80783b61c2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
double calcularDesconto( | |
double valorInicial, double desconto, bool ehPorcentagem) { | |
if (desconto <= 0) | |
throw new ArgumentError("O desconto deve ser maior que zero!"); | |
if (valorInicial <= 0) | |
throw new ArgumentError("O valor inicial deve ser maior que zero!"); | |
if (ehPorcentagem) { | |
return valorInicial - (valorInicial * desconto / 100); | |
} | |
return valorInicial - desconto; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment