Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save nikAizuddin/e6ee27bb8d53b707946a 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 weight
# of the lettuce. The output of the script
# will display the total amount of price base
# on the weight (Assume that 1kg is RM2.50).
#
# Sample output will be:
#
# Enter the weight of lettuce in KG
# [User input]
# Total price is RM[Result]
# Please pay at the counter
#
# Round your answer in 2 dotted decimal.
# ==========================================================
printf("Enter the weight of lettuce in KG\n");
weight = gets.chomp;
total = (weight.to_f * 2.50);
printf("Total price is RM%.2f\n" %total);
printf("Please pay at the counter\n");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment