Advertisement
hackloper775

Ejemplo calculadora bash

Oct 7th, 2012
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.89 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. clear
  4. echo "Calculadora"
  5.  
  6. sleep 1;
  7.  
  8. echo "Escribe un numero: "
  9.  
  10. read numero1
  11.  
  12.     echo "Escribe otro numero:"
  13.  
  14. read numero2
  15.  
  16.     echo "Escribe la operacion(suma resta multiplicacion division)"
  17.  
  18. read operador
  19.  
  20.     case $operador in
  21.  
  22.     Suma|suma)
  23.  
  24.         echo "sumando..."
  25.  
  26.         sleep 2;
  27.  
  28.         (( operacion=$numero1+$numero2 ))
  29.  
  30.         echo "El resultado es $operacion"
  31.         ;;
  32.  
  33.         Resta|resta)
  34.  
  35.         echo "restando..."
  36.  
  37.         sleep 2;
  38.  
  39.         (( operacion=$numero1-$numero2 ))
  40.  
  41.         echo "El resultado es $operacion"
  42.         ;;
  43.  
  44.         Division|division)
  45.  
  46.         echo "dividiendo..."
  47.  
  48.         sleep 2;
  49.  
  50.         (( operacion=$numero1/$numero2 ))
  51.  
  52.         echo "El resultado es $operacion"
  53.         ;;
  54.  
  55.         mutiplicacion|Multiplicacion)
  56.  
  57.         echo "mutiplicando..."
  58.  
  59.         sleep 2;
  60.  
  61.         (( operacion=$numero1*$numero2 ))
  62.  
  63.         echo "El resultado es $operacion"
  64.         ;;
  65.  
  66.         *)
  67.  
  68.         echo 'error saliendo...'
  69.  
  70.         sleep 1;
  71.  
  72.         exit 1;
  73.         esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement