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
Comments
This one is great, I enjoyed doing it
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).
Remember that the Calorie in the final message has a capital C
Make sure you have a period at the end of your print statement..........
>_<
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!
This comment is hidden due to too much negative feedback. Show it anyway.
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
Hello Everyone,
Shouldn't test case 1 be equal to 631, not 649?
Thank you,
Bryce
Read Input specification again. It's burger, side, drink then dessert.
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:
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.
Thank you for your comment. Helped me a lot.
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.Thank you! I tried the solution 3 or 4 times before finding your tip. Fantastic book, minor very frustrating hiccup, but it worked!
Thank you for the hint. I think the same can be achieved using only commands introduced up to that point though:
I think you may be right. Thank you for the tip!
This comment is hidden due to too much negative feedback. Show it anyway.
test case #1
2 1 3 4
Your total Calorie count is 649.
how is it wrong?
You print a, b, c, and d, which isn't identical to the required output.
In other words, just only print the calorie count. Welcome to competitive programming
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.
how can you avoid not having 16 if statements???
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.
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!!!!
Python DictionaryActually just use related lists marshmellon and sugarface are right
Or just related lists
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 :)
I forgot the period!!!!!!
This comment is hidden due to too much negative feedback. Show it anyway.
Your prayers have been answered by google.
Note the word
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.
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.