Created with <3 with dartpad.dev.
Last active
January 14, 2023 00:02
-
-
Save Wils0nDev/9a22fde8ab09acbae945ca5631e9de1b to your computer and use it in GitHub Desktop.
Dart-Calculator
This file contains hidden or 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
void main() { | |
double valor1 = 6; | |
double valor2 = 6.5; | |
List<double> valores = [valor1, valor2]; | |
double resultado = 0; | |
double resultadoPrd = 1; | |
TypeOperation operacion = TypeOperation.SUMA; | |
switch(operacion){ | |
case TypeOperation.SUMA: | |
resultado = valor1 + valor2; | |
break; | |
case TypeOperation.RESTA: | |
resultado=valor1-valor2; | |
if(resultado < 0){ | |
resultado = 0; | |
} | |
break; | |
case TypeOperation.MULTIPLICACION: | |
resultado = valor1 * valor2; | |
break; | |
case TypeOperation.FACTORIAL: | |
for(int i=1; i <= valor1; i++){ | |
resultadoPrd = resultadoPrd * i; | |
} | |
resultado = resultadoPrd; | |
break; | |
case TypeOperation.SUMATORIA: | |
for(int i=0;i<valores.length; i++){ | |
resultado = resultado + valores[i]; | |
} | |
break; | |
case TypeOperation.PRODUCTO: | |
for(int i=0;i<valores.length; i++){ | |
resultadoPrd = resultadoPrd * valores[i]; | |
} | |
resultado = resultadoPrd; | |
break; | |
default: resultado; | |
} | |
print('El resultado de la operación es :$resultado'); | |
} | |
enum TypeOperation { SUMA, RESTA,DIVICION,MULTIPLICACION,FACTORIAL,SUMATORIA,PRODUCTO} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment