dimanche 19 avril 2020

how to get the remainder and calculate the price in ruby?

how should I write this in Ruby??

  • A single book is $35.00
  • books in lots of 4 for $112.00 (so if someone buys 9 books, it would cost $259). this is what I could write:

user_input = gets.chomp.to_f

book_price = 35.00 
if  user_input % 4 == 0 
    book_price = 112.00
else

end

Aucun commentaire:

Enregistrer un commentaire