Skip to content

Instantly share code, notes, and snippets.

Created April 29, 2016 20:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/f1a6deacfeacee412ca4ccffa26d8984 to your computer and use it in GitHub Desktop.
Save anonymous/f1a6deacfeacee412ca4ccffa26d8984 to your computer and use it in GitHub Desktop.
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