Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Problem: It's a hot day, and staying hydrated is important. You
- -- have a cylindrical water bottle with a height and radius. You
- -- plan on going on an adventure which requires you to drink 100
- -- units of water. Given the dimensions of some bottle, print
- -- "Hydrated" if the bottle will hold enough water for you to stay
- -- hydrated during the adventure. Otherwise, print "Thirsty".
- -- Solution: Volume of a cylinder is base times height. Compare this
- -- number to 100 using >=.
- -- Input
- height = 10
- radius = 2
- pi = 3.14159
- -- Calculation
- bottle_volume = pi * radius * radius * height
- -- Output
- if bottle_volume >= 100 then
- print("Hydrated")
- else
- print("Thirsty")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement