my assignment

hi guys..
i have a case from my lecturer

====

Yummy Delivery Pizza is one of the famous pizza shops that you can order many kinds of pizza. As a famous pizza shop, everyday they have so many transaction data that occur. To help them manage the company data, you are asked to create an application using C and C++ language. Here are the rules:

•There are 3 main menus :
1.Order Pizza
2.Pay
3.Exit

•If user chooses “Order Pizza”, then the program will Display the name and price of the pizzas, such as:
1.Meat Lover Pizza (@ Rp. 80000,-)
2.Vegetarian Pizza (@ Rp. 50000,-)

oThen, user is asked to choose which pizza user wants. Validate the input must be between 1 and 2.
oAnd then, the pizza will be added into the transaction.
•If user chooses “Pay”, then the program will:
oIf user has not order any pizza yet, then show display a message “You are not buy anything..”, and back to main menu.
oIf user has order a pizza(s), then show the ordered pizza(s) with total price and ask user to pay.
oValidate the payment should be greater than or equal to total price.
oFinally, show the change of the payment with these following formula:
Change = payment – total price

•If user chooses “Exit”, then the program will end.

===

this are a little part what i can do


#include <iostream>

using namespace std;

void main(){
int i, choice;

do{
for (i=0; i<25; i++){
cout << endl;
}

cout << "Welcome to Yummmy Delivery Pizza" << endl;
cout << "================================" << endl;
cout << "1.Order Pizza" << endl;
cout << "2.Pay" << endl;
cout << "3.Exit" << endl;
cout << "Choose : ";
cin >> choice;

switch (choice){
case 1:
int pizza, hg_1, hg_2, tp;

for (i=0; i<25; i++){
cout << endl;
}

cout << "Choose an order" << endl;
cout << "===============" << endl;
cout << "1. Meat Lover Pizza (@ Rp. 80000,-)" << endl;
cout << "2. Vegetarian Pizza (@ Rp. 50000,-)" << endl;

do{
cout << "Which pizza do you want to order[1-2]: ";
cin >> pizza;
}while(pizza < 1 || pizza > 2);

switch (pizza){
case 1:
hg_1 = 80000;
cout << "Thank you...";
break;

case 2:
hg_2 = 50000;
cout << "Thank you...";
break;

break;
}

case 2:

break;
}

}while(choice != 3);

cin.get();
}


===

i'have tried to make it
but i can't continue it
can you help me because i don't know what should i do ??




im working on it :)
Use switch inside anothe switch:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
switch(choice)
{
case 1:
    int pizza;
    cin>>pizza;

    switch(pizza)
    case 1:
    //meat pizza;
    break;
    
    case 2:
    //veggie pizza
    break;

break;

case 2:
//pay
break;

case 3:
//exit
break;
#include <iostream>

using namespace std;

void clearScreen(){
for (int i=0; i<30; i++){
cout << endl;
}
}

int main(){
int choice, pizza, meatlover=0, vegetarian=0, hg_2, totalcost=0;
char cartoption;
do{
clearScreen();
cout << "Welcome to Yummmy Delivery Pizza" << endl;
cout << "================================" << endl;
cout << "1. Order Pizza" << endl;
cout << "2. Pay" << endl;
cout << "3. Exit" << endl;
cout << "Choose : ";
cin >> choice;

switch (choice){
case 1:
clearScreen();
cout << "Choose an order" << endl;
cout << "===============" << endl;
cout << "1. Meat Lover Pizza (@ Rp. 80000,-)" << endl;
cout << "2. Vegetarian Pizza (@ Rp. 50000,-)" << endl;
do{
cout << "Which pizza do you want to order[1-2]: ";
cin >> pizza;
}while(pizza < 1 || pizza > 2);

switch (pizza){
case 1:
meatlover = meatlover + 1;
clearScreen();
cout << "You added a MeatLovers pizza to the cart.";
break;
case 2:
vegetarian = vegetarian + 1;
cout << "You added a Vegetarian pizza to the cart.";
break;
}
break;
case 2:
clearScreen();
if(meatlover+vegetarian==0){
cout << "You did not buy anything." << endl;
cout << "Would you like to continue shopping? Y/N ";
cin >> cartoption;
if(cartoption == 'N' || cartoption == 'n'){
choice=3;
}
}else{
cout << "Meatlovers(" << meatlover << "): " << meatlover*80000 << endl;
cout << "vegetarian(" << vegetarian << "): " << vegetarian*50000 << endl;
cout << "Total Cost: " << (meatlover*80000)+(vegetarian*50000) << endl;
cout << "Are you happy with your order? Y/N ";
cin >> cartoption;
if(cartoption == 'Y' || cartoption == 'y'){
choice=3;
}
}
break;
}

}while(choice != 3);
}
Last edited on
thanks a lot to you all.. XD

you make me understand with your answer..
Topic archived. No new replies allowed.