Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save nikAizuddin/50c1b601dd3f4a6bf4b9 to your computer and use it in GitHub Desktop.
BCN2053 Operating System Lab Sheet 6 (RUBY)
#!/bin/ruby
# ==========================================================
# 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
# ==========================================================
printf("What is your name?\n");
name = gets.chomp;
printf("What is your last semester GPA?\n");
gpa = gets.chomp;
cgpa = 3.5;
cgpa = (gpa.to_f + cgpa.to_f).to_f.fdiv(2.to_f);
printf("Your CGPA is %.2f\n" %cgpa);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment