Results 1 to 4 of 4

Math Help - C++ programming. i need help !

  1. #1
    Junior Member
    Joined
    Feb 2013
    From
    Canada
    Posts
    31

    C++ programming. i need help !

    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: Here are the three drink choices:
    1 – Cheeseburger (461 Calories) 1 – Soft Drink ( 130 Calories)
    2 – Fish Burger (431 Calories) 2 – Orange Juice (160 Calories)
    3 – Veggie Burger (420 Calories) 3 – Milk (118 Calories)
    4 – no burger 4 – no drink
    Here are the three side order choices: Here are the three dessert choices:
    1 – Fries (100 Calories) 1 – Apple Pie (167 Calories)
    2 – Baked Potato (57 Calories) 2 – Sundae (266 Calories)
    3 – Chef Salad (70 Calories) 3 – Fruit Cup (75 Calories)
    4 – no side order 4 – no dessert
    Write a program that will compute the total Calories of a meal.
    Input Specifications
    The program should prompt the user for a number for each type of item then calculate and display the Calorie total. 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 Specifications
    The program prints out on the screen the total Calories of the selected meal, and stops executing
    after this output.
    Sample Prompting and User Input (user input in italics)
    Welcome to Chip’s Fast Food Emporium
    Please enter a burger choice: 2
    Please enter a side order choice: 1
    Please enter a drink choice: 3
    Please enter a dessert choice: 4
    Output for the Sample
    Your total Calorie count is 649.



    above is the question and below is my half code so far....i can't further do anything.......i can't under stand what should i do?




    #include <iostream>


    using namespace std;


    int main()
    {
    int b,d,o,s;
    int a=
    int sum=0;
    cout<<"Welcome to Chip's Fast Food Emporium"<<endl;
    cout<<"Please enter a burger choice:"<<endl;
    cin>>b;
    cout<<"Please enter a side order choice:"<<endl;
    cin>>o;
    cout<<"Please enter a drink choice:"<<endl;
    cin>>d;
    cout<<"Please enter a dessert choice:"<<endl;
    cin>>s;


    return 0;
    }
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Senior Member jakncoke's Avatar
    Joined
    May 2010
    Posts
    387
    Thanks
    80

    Re: C++ programming. i need help !

    Create an 4 arrays that store the calories, one for burger, one for side, one for drink and one for dessert.

    If the user picks the 5th option for burger, this corresponds to the 4th index of your burger array( since index start with 0).

    So if you had an array Burger and the user input to get burger choice was stored in a variable.
    Type cast that variable to an int, and - 1 and use this as an index Burger[input - 1] to get the calories for that choice.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Junior Member
    Joined
    Feb 2013
    From
    Canada
    Posts
    31

    Re: C++ programming. i need help !

    can you type the code for arrays...cause i hav no idea what you talking about?
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Senior Member jakncoke's Avatar
    Joined
    May 2010
    Posts
    387
    Thanks
    80

    Re: C++ programming. i need help !

    #include <iostream>

    using namespace std;

    int main()
    {
    int burgerCalories [] = {461,431};
    int sideOrder [] = {100,57};
    int drink [] = {130,160};
    int dessert [] = {167,266};


    int burgerChoice,sideOrderChoice,drinkChoice,dessertCh oice;
    int totalCalories;

    cout<<"Please enter burger choice :"<<endl;
    cin>>burgerChoice;

    cout<<"Please enter side order choice:"<<endl;
    cin>>sideOrderChoice;

    cout<<"Please enter drink choice :"<<endl;
    cin>>drinkChoice;

    cout<<"Please enter dessert choice :"<<endl;
    cin>>dessertChoice;

    totalCalories = burgerCalories[burgerChoice-1] + sideOrder[sideOrderChoice-1] + drink[drinkChoice-1]
    + dessert[dessertChoice-1];

    cout<<"Total Calories Consumed "<<totalCalories<<endl;
    return 0;
    }

    This code only has the first 2 choices of each burger, desert, etc.. you gave on your menu, it should be easy to extend it.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Replies: 8
    Last Post: February 20th 2013, 08:35 PM
  2. Replies: 3
    Last Post: February 20th 2013, 07:16 PM
  3. Programming For HP 48G+
    Posted in the Calculators Forum
    Replies: 0
    Last Post: February 3rd 2009, 04:09 AM
  4. Replies: 1
    Last Post: November 17th 2008, 04:18 AM
  5. Please help on R programming
    Posted in the Math Software Forum
    Replies: 0
    Last Post: August 16th 2008, 03:51 AM

Search Tags


/mathhelpforum @mathhelpforum