Advertisement
Rnery

Media Calculator..

Jun 25th, 2022 (edited)
1,149
1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.78 KB | Source Code | 1 0
  1. #!/usr/bin/env bash
  2.  
  3. clear
  4.  
  5. _get_entries() {
  6.     read -rp "Nome do aluno: " nome
  7.  
  8.     echo -e "\nDigite a nota do aluno: "
  9.     read -r nota_um
  10.     read -r nota_dois
  11.     read -r nota_tres
  12. }
  13.  
  14. _get_media() {
  15.     echo "$nota_um, $nota_dois, $nota_tres"
  16.  
  17.     #MEDIA=$(((nota_um+nota_dois+nota_tres)/3)) com números inteiros
  18.     MEDIA=$(bc -l <<< "($nota_um+$nota_dois+$nota_tres)/3") # números float
  19. }
  20.  
  21. _verify_media() {
  22.     if [[ $(echo "$MEDIA >= 5" | bc) == 1 ]]
  23.     then
  24.         echo -e "\nSua nota é $MEDIA. Parabéns $nome você passou de ano!"
  25.         printf "\nSua nota é %.2f Parabéns %s você passou de ano!" ${MEDIA} ${nome}
  26.     else
  27.         echo -e "\nBurrão! sua nota é $MEDIA! Melhora essa bosta!"
  28.     fi
  29. }
  30.  
  31. _get_entries
  32. _get_media
  33. _verify_media
  34.  
Tags: BASH
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement