Created
April 29, 2016 20:40
-
-
Save anonymous/f1a6deacfeacee412ca4ccffa26d8984 to your computer and use it in GitHub Desktop.
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
begin | |
#Get the amount of the purchase before taxes. | |
print "Purchase amount: " | |
sale = Float(gets.chomp) | |
#Don't give me text. | |
rescue | |
puts "Error: Not a number, or no number entered." | |
retry | |
#Define the tax values. | |
stax = sale * 0.05 | |
ctax = sale * 0.025 | |
#Calculate the total sale | |
total = sale + stax + ctax | |
puts "Purchase: #{sale}" | |
puts "State tax: #{stax}" | |
puts "County tax: #{ctax}" | |
puts "Total sale: #{total}" | |
puts "Have a nice day." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment