Created
November 30, 2014 19:45
-
-
Save nikAizuddin/e6ee27bb8d53b707946a to your computer and use it in GitHub Desktop.
BCN2053 Operating System Lab Sheet 6 (RUBY)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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