191k views
2 votes
A bag of cookies holds 30 cookies. The calorie information on the bag claims that there are 10 "servings" in the bag and that a serving equals 240 calories. Write a program that asks the user to input how many cookies they actually ate and then reports how many total calories were consumed.

User Thebiglife
by
6.2k points

1 Answer

4 votes

Final answer:

To find the total number of calories consumed, calculate the number of servings the student ate and then multiply by the number of calories per serving. If the student ate a certain number of cookies, divide by the number of cookies in one serving to find how many servings they ate. Finally, multiply that number by the number of calories per serving to find the total number of calories consumed.

Step-by-step explanation:

To find the total number of calories consumed, you need to calculate the number of servings the student ate and then multiply it by the number of calories per serving.

Since there are 10 servings in the bag of cookies, and each serving equals 240 calories, the total number of calories in the bag is 10 servings x 240 calories/serving = 2400 calories.

If the student ate a certain number of cookies, you can divide that number by the number of cookies in one serving (30 cookies) to find how many servings they ate. Then, multiply that number by the number of calories per serving (240 calories) to find the total number of calories consumed.

User Madcolor
by
6.7k points