CCC '06 J1 - Canadian Calorie Counting

View as PDF

Submit solution

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

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


Comments


  • 2
    oscarhuang885  commented on July 20, 2022, 7:42 p.m.

    Why buy food?


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

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


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

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

    _<


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

    Burger #2 = 431

    Side #1 = 130

    Drink #3 = 70

    Dessert #4 = 0

    Total = 631

    How is the correct answer 649? Am I missing something?


    • -2
      Impendable  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


  • -3
    Xaalderan  commented on May 25, 2022, 4:14 p.m.

    The exercise is cool and all but what even is this menu?


  • -1
    bmarshall07  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


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

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


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

    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.


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

      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.


    • -2
      Nordic_Monkey  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!


    • 0
      s9adzahn  commented on March 24, 2022, 4:05 a.m. edit 2

      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) + '.')


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

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


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

    I see 'welcome to competitive programming' So if I understand, that's why my shit was working fine, but wouldn't pass, because, I LITERALLY Just need to Capitalize the God Damn 'C' in Calorie to have it be accepted.

    Edit: Frustrates me because it took me a lot longer than needed. BUT I do feel accomplished that i was able to troubleshoot it down to being a problem with capitalization on the printed output.


  • -1
    Rodrigo2022  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?


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

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


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

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


  • 2
    cyopotatoe  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.


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

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


      • -1
        jasonreeson  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.


        • -1
          Sugarface  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!!!!


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

        Python Dictionary

        Actually just use related lists marshmellon and sugarface are right


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

          Or just related lists


    • 7
      AlanL  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 :)


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

    I forgot the period!!!!!!


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

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


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

      Your prayers have been answered by google.


    • 6
      Super_User  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.


  • 16
    aeternalis1  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.