Created
January 25, 2015 00:15
-
-
Save jjb/fcda61801b54cc3f13d1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
print "Fat: " | |
fat = gets.strip | |
print "Protein: " | |
protein = gets.strip | |
print "Carbohydrates: " | |
carbs = gets.strip | |
fat_calories = fat.to_f*9 | |
carb_calories = carbs.to_f*4 | |
protein_calories = protein.to_f*4 | |
total_calories = fat_calories + carb_calories + protein_calories | |
fat_portion = ((fat_calories/total_calories) * 100).truncate | |
protein_portion = ((protein_calories/total_calories) * 100).truncate | |
carb_portion = ((carb_calories/total_calories) * 100).truncate | |
output = "" | |
output << "Total Calories: #{total_calories}" | |
output << "\n\n" | |
output << "Fat/Protein/Carb ratio: #{fat_portion}%/#{protein_portion}%/#{carb_portion}%" | |
puts output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment