program help

Hi I am new to C++, I am having some dificulty creating this program. If any one can help solve I'd greatly appreciate the help.

Design a Burger King self order program that accepts customer’s order and finishes the
transaction. Suppose there are three types of burgers:
1. Burger ($2.00)
2. Bacon Burger ($2.50)
3. Cheese Burger ($2.50)
There are three types of drinks:
1. Diet Coke ($1.00)
2. Mountain Dew ($1.00)
3. Beer ($2.00)
Your program should run as follows,
(1). First, ask the customer which burger he/she wants.
(After customer gives the correct input.)
(2). Second, ask the customer which drink he/she wants.
(After customer gives the correct input.)
(3). Compute the total price for the customer (tax rate: 8%).
(4). Then serve the next customer until there is no customer left.
Did you attempt this yourself? if so we need to see your code. We appreciate it if you at least attempt to try to program it.
this is what i have.....

#include <iostream>

#include <cmath>

#include <string>



double price[7] = {15.80 , 10.50 , 19.00 , 14.00 , 12.00 , 22.00 , 16.00 };

double mealTaxPrices[7];

int burgerChoice, drinkChoice;





void printMeals();

void orderMeals();

double orderForBurger();

double orderForDrink();

int main()

{

char response = 'y';





printMeals();

while(response == 'y'|| response == 'Y')

{

printf("please enter number for Burger:");

scanf("%d",&burgerChoice);



printf("please enter number for Drink:");

scanf("%d",&drinkChoice);





orderMeals();



printf("\nwould you like to continue(y/n):");

scanf("\n%c",&response);

}



printf("\n ******************** THANK YOU FOR COMING *************************\n");

printf("\20********************** PLEASE VISIT US NEXT TIME **************************\20 \n");

system("pause");

return 0;

}



void printMeals()

{



printf("\20******************* WELCOME TO BURGER KING **************************\20\n");

printf(" \t\t\t Below is the menue:\20\n");

printf(" \t\t\t MEALS\t\t\tPRICE:\n");

printf(" \t\t\t \22*******************************\22\n");

printf(" \t\t\t 1- Burger\tRM2.00\n");

printf(" \t\t\t 2- Bacon Burger\t\tRM2.50\n");

printf(" \t\t\t 3- Cheese Burger\tRM2.50\n");

printf(" \t\t\t 4- Diet Coke\tRM1.00\n");

printf(" \t\t\t 5- Mountain Dew\tRM1.00\n");

printf(" \t\t\t 6- Beer\t\2.00\n");









printf("\n");

}

void orderMeals()

{

double totalPriceForBurger, totalPriceForDrink;

double allPayment,discount;

printf(" \t\t**** ORDER MENU****\n");





totalPriceForBurger = orderForBurger();

totalPriceForDrink = orderForDrink();

allPayment = totalPriceForBurger + totalPriceForDrink ;



printf("\n \t\t \22**************************************\22 \n");

printf(" \t\t ****************** final BILL ************ \n");

printf(" \t\t\tburger/drink\tcount\t\ttotal price\n");

printf(" \t\t\tburger\t\t%d\t\t%5.2f\n",burgerChoice,totalPriceForBurger);

printf(" \t\t\tdrink\t%d\t\t%5.2f\n",drinkChoice,totalPriceForDrink);

printf(" \t\t\tTotal bill\t\t\t%5.2f\n",allPayment );







if(allPayment < 10)

discount=((allPayment * 0.5)/100);

else if(allPayment>= 10 && allPayment<20)

discount=((allPayment * 1)/100);

else if(allPayment>= 20 && allPayment<30)

discount=((allPayment * 1.5)/100);

else if(allPayment>= 30 && allPayment<40)

discount=((allPayment * 2.0)/100);

else

discount= ((allPayment * 5.0)/100);



printf(" \t\t\tTotal bill after discount\t%5.2f\n",allPayment-discount);



}

double orderForBurger()

{

int menuOption,i,amount;

char response = 'y';

double totalPerBurger = 0.0,totalAllDrink = 0.0;

double tax = 8.0;

double totalAllBurger;


if(burgerChoice <=0)

printf("\n ");

else

printf("*\tburger:\n");

for(i=0;i<burgerChoice;i++)

{

printf("burger %d Please enter your orders\n",i+1);

while(response == 'y' || response == 'Y')

{

printf("please enter your option:");

scanf("%d",&menuOption);

if(menuOption<1 || menuOption>7)

{

printf("Sorry we don`t have this order \nagain! ");

continue;

}

printf("Please enter your amount of order:");

scanf("%d",&amount);





totalPerBurger = totalPerBurger + (amount * price[menuOption - 1] );



printf("\nWould you like to enter more orders(y/n):");

scanf("\n%c",&response);







}

printf("\n");

totalAllBurger += totalAllBurger + totalPerBurger;

totalPerBurger = 0.0;

response = 'y';

}



return totalAllBurger + ((totalAllBurger * tax) / 100);

}

double orderForDrink()

{

int menuOption,i,amount;

char response = 'y';

double totalPerDrink = 0.0,totalAllDrink = 0.0;

double tax = 8.0,oneOrder;

if(drinkChoice <=0)

printf("\n");

else

printf("*\tDrink:\n");

for(i=0;i<drinkChoice;i++)

{

printf("Drink %d Please enter your orders\n",i+1);

while(response == 'y' || response == 'Y')



printf("Please enter your option:");

scanf("%d",&menuOption);

if(menuOption<1 || menuOption>7)

{

printf("Sorry we don`t have this order \nagain! ");

continue;

}

printf("Please enter your amount of order:");

scanf("%d",&amount);



oneOrder = (price[menuOption - 1] * tax)/100 ;

totalPerDrink = totalPerDrink + (amount * oneOrder) ;



printf("Would you like to enter more orders(y/n):");

scanf("\n%c",&response);





}

totalAllDrink += totalAllDrink + totalPerDrink;

response = 'y';

totalPerDrink = 0.0;



printf("\n");


return totalAllDrink + ((totalAllDrink * tax) / 100);




system("pause");

return 0;
}
that seems a little more complicated than it needs to be but maybe im not seeing what your fully trying to do, but here is my code. Its not fully complete but i think its best you complete it since your still learning.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <iostream>
#include <string>

using namespace std;

//Global Variable
double total = 0;

int main()
{
    string choice1;
    string choice2;

    cout << "Welcome to Burger King please place your order" << endl;
    cout << "Please input only the number next to the order you want" << endl;
    cout << "\n";
    cout << "BURGERS" << endl;
    cout << "1. Burger - $2.00" << endl;
    cout << "2. Bacon Burger - $2.50" << endl;
    cout << "3. Cheese Burger - $2.50" << endl;
    cin >> choice1;

    if(choice1 == "1" || choice1 == "1.")
    {
        total += 2.00;
    }
    else if(choice1 == "2" || choice1 == "2.")
    {
        total +=2.50;
    }
    else if(choice1 == "3" || choice1 == "3.")
    {
        total +=2.50;
    }

    cout << "\n";
    cout << "What would you like to drink?" << endl;
    cout << "DRINKS" << endl;
    cout << "4. Diet Coke - $1.00" << endl;
    cout << "5. Mountain Dew - $1.00" << endl;
    cout << "6. Beer - $2.00" << endl;
    cin >> choice2;

    if(choice2 == "4" || choice2 == "4.")
    {
        total += 1.00;
    }
    else if(choice2 == "5" || choice2 == "5.")
    {
        total += 1.00;
    }
    else if(choice2 == "6" || choice2 == "6.")
    {
        total += 2.00;
    }

    cout << "Your total comes to $" << total << endl;
 }


Also please put your code between code tags.
Last edited on
I really appreciate your help so far. But unfortunately I feel lost. Ive been working on this project for a week already, and as you can see I'm not just looking to be lazy. But it would really help if I could get this problem figured out, because I can't seem to figure it out. If you think you can help me I'd gladly appreciate it as I dn't have much time left to turn this in.
I will help you as best i can, but why are you using printf and scanf instead of cout and cin??
honestly I thought thats how you were supposed to do it. Its a little trickey for me.
How are you currently learning C++?
taking a class
I would suggest you watch these:

http://www.youtube.com/watch?v=SWZfFNyUsxc&list=PLAE85DE8440AA6B83&index=2&feature=plpp_video

This is how i learned C++. He makes a point of explaining everything so you understand it. He has 73 C++ tutorials in total.
Last edited on
I appreciate the tips, I will give those a look. Would you be able to figure out the rest of this program?
I myself am a beginner at c++, this is the best i can help you. my suggestion would be to go to the general C++ programming area and ask there. or wait for someone else to help. sorry i could not help you further.
Or just read a little in the forum: http://www.cplusplus.com/forum/beginner/66056/
Topic archived. No new replies allowed.