The text below is selected, press Ctrl+C to copy to your clipboard. (⌘+C on Mac) No line numbers will be copied.
Guest
Marklinux
By Guest on 26th March 2024 05:46:55 AM | Syntax: PYTHON | Views: 66



New Paste New paste | Download Paste Download | Toggle Line Numbers Show/Hide line no. | Copy Paste Copy text to clipboard
  1.  #!/bin/bash
  2.      
  3.     echo "Enter the first mark: "
  4.     read mark1
  5.     echo "Enter the second mark: "
  6.     read mark2
  7.     echo "Enter the third mark: "
  8.     read mark3
  9.      
  10.     total=$(echo "$mark1 + $mark2 + $mark3" | bc)
  11.     avg=$(echo "scale=2; ($mark1 + $mark2 + $mark3) / 3" | bc)
  12.      
  13.     if (( $(echo "$avg >= 90 && $avg <= 100" | bc -l) )); then
  14.         grade="A"
  15.     elif (( $(echo "$avg >= 80 && $avg < 90" | bc -l) )); then
  16.         grade="B"
  17.     elif (( $(echo "$avg >= 70 && $avg < 80" | bc -l) )); then
  18.         grade="C"
  19.     elif (( $(echo "$avg >= 60 && $avg < 70" | bc -l) )); then
  20.         grade="D"
  21.     else
  22.         grade="F"
  23.     fi
  24.      
  25.     echo "Grand total of m1,m2,m3 out of 300 = $total"
  26.     echo "The percentage = $avg"
  27.     echo "The grade = $grade"





marklinux