Created
June 9, 2013 01:48
-
-
Save jamesmichiemo/5737281 to your computer and use it in GitHub Desktop.
expressions in Ruby Language
This file contains 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
# Discount exercise | |
# Calculate the discounted price for an item | |
# | |
print "What is the name of the item you would like to buy? " | |
itemDescription = gets.chomp() | |
print "What is the price of one #{itemDescription}? " | |
price = gets.chomp().to_f | |
print "At what percent is the discount offered? " | |
priceDiscount = gets.chomp().to_i | |
print "At what percent is the sales tax for purchases? " | |
salesTax = gets.chomp().to_f | |
taxTotal = (price - (price * (priceDiscount * 0.01)) + (price * salesTax * 0.01)); | |
priceTotal = price - (price * (priceDiscount * 0.01)); | |
puts "Your #{itemDescription} was originally priced at $#{price}, but after a #{priceDiscount}% discount, it is now $#{priceTotal} without tax, and $#{taxTotal} with tax."· |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment