Skip to content

Instantly share code, notes, and snippets.

@nikAizuddin
Created November 30, 2014 19:49
Show Gist options
  • Select an option

  • Save nikAizuddin/e99280526fad9a57a0c1 to your computer and use it in GitHub Desktop.

Select an option

Save nikAizuddin/e99280526fad9a57a0c1 to your computer and use it in GitHub Desktop.
BCN2053 Operating System Lab Sheet 6 (BASH)
#!/bin/bash
# ==========================================================
# This script requires user to input the name and last
# semester GPA. The output of the script will display your
# current CGPA (Assume that your current CGPA for 2 semester
# is 3.5).
#
# Sample output will be:
#
# What is your name?
# [User input]
# What is your last semester GPA?
# [User input]
# Your CGPA is [Result]
#
# Round your answer in 2 dotted decimal
# ==========================================================
echo "What is your name?"
read name
echo "What is your last semester GPA?"
read gpa
cgpa=3.5
cgpa=`echo "scale=2; ($cgpa + $gpa) / 2" | bc -l`
echo "Your CGPA is $cgpa"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment