CCC '06 J1 - Canadian Calorie Counting

View as PDF

Points: 3
Time limit: 2.0s
Memory limit: 256M

Problem type
Canadian Computing Competition: 2006 Stage 1, Junior #1

At Chip's Fast Food emporium there is a very simple menu. Each food item is selected by entering a digit choice.

 Here are the three burger choices: 1 – Cheeseburger (461 Calories) 2 – Fish Burger (431 Calories) 3 – Veggie Burger (420 Calories) 4 – no burger Here are the three drink choices: 1 – Soft Drink (130 Calories) 2 – Orange Juice (160 Calories) 3 – Milk (118 Calories) 4 – no drink Here are the three side order choices: 1 – Fries (100 Calories) 2 – Baked Potato (57 Calories) 3 – Chef Salad (70 Calories) 4 – no side order Here are the three dessert choices: 1 – Apple Pie (167 Calories) 2 – Sundae (266 Calories) 3 – Fruit Cup (75 Calories) 4 – no dessert

Write a program that will compute the total Calories of a meal.

Input Specification

The program should input a number for each type of item then calculate and display the Calorie total. The first line will be the customer's choice of burger, the second will be the choice of side, then drink, then dessert. You may assume that each input will be a number from 1 to 4. That is, each customer has to pick exactly one number from each of the four options out of each of the four categories.

Output Specification

The program prints out the total Calories of the selected meal, and stops executing after this output.

Sample Input

2
1
3
4

Sample Output

Your total Calorie count is 649.

Explanation

The customer chose Burger #2, Side #1, Drink #3 and Dessert #4.

CCC problem statements in large part from the PEG OJ

• commented on Nov. 10, 2022, 1:29 p.m.

This one is great, I enjoyed doing it

• commented on Nov. 5, 2022, 9:33 a.m. edited

It took me a really long time to realize that I completely mixed up the order wrongly. Don't forget to start with the burgers, then the side order, and only then the soft drink and dessert (I swapped the side order with the soft drink).

• commented on July 1, 2022, 9:13 p.m.

Remember that the Calorie in the final message has a capital C

• commented on June 28, 2022, 7:11 p.m. edited

Make sure you have a period at the end of your print statement..........

>_<

• commented on Nov. 7, 2022, 3:34 p.m.

Uhhhhgggg I wish I read this before figuring it out on my own. I was getting all the correct outputs but couldn't figure out while I was still failing until I looked at the print output. There should be a little more leniency on trivial stuff like that or at least note that lack of punctuation and capitalization will result in a failed score.

I'm here to learn how to code not get an English lecture!

• commented on May 30, 2022, 3:49 a.m. edited

This comment is hidden due to too much negative feedback. Show it anyway.

• commented on June 9, 2022, 5:44 p.m.

Burger #2 = 431 Side #1 = 100 Drink #3 = 118 Dessert #4 = 0

431 + 100 + 118 = 649

You've confused the drink and side I believe

• commented on April 6, 2022, 8:30 p.m.

Hello Everyone,

Shouldn't test case 1 be equal to 631, not 649?

Thank you,

Bryce

• commented on April 6, 2022, 8:59 p.m.

Read Input specification again. It's burger, side, drink then dessert.

• commented on March 18, 2022, 9:15 p.m. edited

If you are doing this problem because you are going through the book "Learn to Code By Solving Problems", before you get so frustrated you break your laptop because you think you have done everything right and still can't get your code to pass, try printing your results in this format:

print(f'Your total Calorie count is {variable_goes_here}.')


The author has made no mention of this in the book yet, so it was very frustrating for me to realize the only reason my code wasn't passing was that the author gave us an example to work and submit without covering the correct syntax to get it to pass.

• commented on Oct. 15, 2022, 2:43 a.m.

Thank you for your comment. Helped me a lot.

• commented on Aug. 12, 2022, 1:01 a.m. edited

The f print does indeed work, but you can also just use a concatenation with all elements of the output. As in: print('Your total Calorie count is ' + str(total) + '.') This worked find for me, and this is already covered in the learn to code book by this point.

• commented on May 25, 2022, 5:48 a.m.

Thank you! I tried the solution 3 or 4 times before finding your tip. Fantastic book, minor very frustrating hiccup, but it worked!

• commented on March 24, 2022, 4:05 a.m. edit 3

Thank you for the hint. I think the same can be achieved using only commands introduced up to that point though:

print('Your total Calorie count is ' + str(total_calories) + '.')

• commented on May 25, 2022, 5:49 a.m.

I think you may be right. Thank you for the tip!

• commented on March 10, 2022, 2:10 p.m. edited

This comment is hidden due to too much negative feedback. Show it anyway.

• commented on March 2, 2022, 10:52 a.m. edited

test case #1

2 1 3 4

Your total Calorie count is 649.

how is it wrong?

• commented on March 2, 2022, 11:05 a.m.

You print a, b, c, and d, which isn't identical to the required output.

• commented on March 4, 2022, 10:03 p.m.

In other words, just only print the calorie count. Welcome to competitive programming

• commented on May 26, 2020, 2:50 p.m. edit 3

I'm the wonderful stupid idiot who made 16 if statements only to realize that I was being stupid. Also, isn't the sample output supposed to be 631 cals? Maybe my calculator is broken so please don't come at meh. Maybe that's why I got everything wrong.

• commented on Dec. 26, 2020, 5:17 p.m. edited

how can you avoid not having 16 if statements???

• commented on Sept. 3, 2021, 10:03 a.m.

Sorry to bug you. I'm learning Python and the book I'm using uses these tests. Up this point in the book we have covered if statements. I'm curious how you'd handle this without 16 if statements? What did I miss?? Thanks in advance.

• commented on Sept. 8, 2021, 9:38 p.m.

Before you read this comment this talks about ArrayLists! So the basic code I used was 4 if loops to check if it was a burger, side, drink, or dessert. Then I had 4 ArrayLists consisting of the costs of each item. Then you can take in your input(2 1 3 4). The first number stands for burger. I would use the line "cost += burgers.get(2-1)". This line means that the you are adding the cost with the ArrayList burgers. Then you use the get() function to get a specific number from the ArrayList for this example 2-1. You may ask why not 2? Its because you want the second item from your ArrayList and the index for the second item is 1 not 2. So you would put in 2-1. I hope this helps!!!!

• commented on March 1, 2021, 12:23 p.m. edit 2

Python Dictionary

Actually just use related lists marshmellon and sugarface are right

• commented on April 25, 2021, 3:20 p.m.

Or just related lists

• commented on May 26, 2020, 7:53 p.m.

If you read the input specifications, they give you the input for for a side first, then a drink, not the other way around. Hope that fixes your problem :)

• commented on Dec. 4, 2018, 10:56 p.m.

I forgot the period!!!!!!

• commented on Aug. 26, 2018, 1:37 p.m.

This comment is hidden due to too much negative feedback. Show it anyway.

• commented on May 26, 2020, 2:55 p.m. edited

• commented on Dec. 28, 2019, 10:41 p.m.

Note the word

Veggie Burger

A burger has 295 calories (according to Google). A sundae has 180 calories (according to Google).

It seems as if the calories were more/less doubled.

• commented on Nov. 19, 2017, 8:41 a.m. edited

Rather than asking for help in comments, which severely clutters up the comments stream, you can go to https://discord.com/invite/EgJVpxz and ask for help in the #help channel. You will be able to get quicker responses and better explanations.