Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # !/bin/bash
- # Assunto: Calculos Matematicos
- # Compilar: chmod 777
- ## Script ##
- echo ""
- # Funcao
- soma()
- {
- soma=`echo "scale=2; ($n1 + $n2)" | bc `
- echo "- Soma: $soma"
- }
- subtracao()
- {
- sub=`echo "scale=2; ($n1 - $n2)" | bc`
- echo "- Subtracao: $sub"
- }
- multiplicacao()
- {
- mult=`echo "scale=2; ($n1 * $n2)" | bc`
- echo "- Multiplicacao: $mult"
- }
- divisao()
- {
- div=`echo "scale=2; ($n1 / $n2)" | bc`
- echo "- Divisao: $div"
- }
- potenciacao()
- {
- pot=`echo "scale=2; ($n1 ^ $n2) " | bc`
- echo "- Potenciacao: $pot"
- }
- raizQuadrada()
- {
- rq1=`echo "scale=2; sqrt( $n1 )" | bc`
- rq2=`echo "scale=2; sqrt( $n2 )" | bc`
- echo "- Raiz Quadrada(N1): $rq1"
- echo "- Raiz Quadrada(N2): $rq2"
- }
- # Programa
- echo ""
- echo "---------- CALCULADORA ----------"
- # Entrada de dados
- read -p "Digite N1: " n1
- read -p "Digite N2: " n2
- # Saida de dados & chamada de funcao
- echo ""
- echo "------- RESULTADO ----------"
- soma
- subtracao
- multiplicacao
- potenciacao
- raizQuadrada
- echo "----------------------------"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement