where and how do I add array statement and ofstream?

#include <iostream>
using namespace std;


int main(int argc, char** argv) 


{
int size, crust, flavor, extra, order=0, total=0;

cout<<"Good day! Welcome to Don Rogelio's Pizza. \n";
do{
cout<<"\nPizza size: (1)Small (2)Medium (3)Large  :";
cin>>size;
cout<<"\nPizza Crust: (1)Thin Crust (2)Regular Crust  :";
cin>>crust;
cout<<"\nPizza Flavor: (1)Hawaiian (2)Pepperoni (3)Ham & Cheese (4)All Meat (5)All Cheese (6)Vegetarian  :";
cin>>flavor;
cout<<"\nAdditional/Extras: (1)Pepperoni (2)Pineapple (3)Ham (4)Veggies (5)Meat (6)Cheese (7)None  :";
cin>>extra;



switch(size)
{
case 1: cout<<"Your order is small"; 
total=total+30; break;
case 2: cout<<"Your order is medium";
total=total+50; break;
case 3: cout<<"Your order is large";
total=total+70; break;
default: cout<<"Invalid input."; break;
}
switch(crust)
{
case 1: cout<<" thin crust"; 
total=total+35; break;
case 2: cout<<" regular crust ";
total=total+30; break;
default: cout<<"\nInvalid input."; break;
}
switch(flavor)
{
case 1:  cout<<" hawaiian pizza"; total=total+50; break;
case 2:  cout<<" pepperoni pizza"; total=total+65; break;
case 3:  cout<<" ham & cheese pizza"; total=total+50; break; 
case 4:  cout<<" all meat pizza"; total=total+80; break;
case 5:  cout<<" all cheese pizza"; total=total+50; break;
case 6:  cout<<" vegetarian pizza"; total=total+60; break;
default: cout<<"\nInvalid input."; break;
}
switch(extra)
{
case 1:  cout<<" with extra pepperoni.\n"; total=total+10; break; 
case 2:  cout<<" with extra pineapple.\n"; total=total+15; break;
case 3:  cout<<" with extra ham.\n"; total=total+10; break;
case 4:  cout<<" with extra veggies.\n"; total=total+15; break;
case 5:  cout<<" with extra meat.\n"; total=total+20; break;
case 6:  cout<<" with extra cheese.\n"; total=total+15; break;
case 7:  cout<<" with no extra.\n"; break;
default: cout<<"\nInvalid input."; break;
}
cout<<"Would you like to change your order? (1)YES (2)NO: ";
cin>>order;
switch(order)
{
case 1: order=order +0; break;
case 2: order=order +1; break;  
}
}
while(order==1);
{
cout<<"\n";
cout<<"\nThe total is " <<total; 
cout<<" PHP.";






    }return 0;
}

What exactly are you trying to accomplish with the array and ofstream?

i want to output the final order in notepad. about the array i don't have idea. My professor said it must contain array amd ofstream. Kindly help me ASAP if ever. Thank you in advance :D

In order top use an array effectively, you would need to make each pizza an object. This will require a custom class. Something like this:

class Pizza
{
public:
    struct Item
    {
        string item = "";
        int cost = 0;
    }
    Pizza(Item _size, Item _crust, Item _flavor, vector<Item> _extras);
    int CalculateCost();
    string PrintPizza(ofstream& out);
private:
    Item size;
    Item crust;
    Item flavor;
    vector<Item> extras;
};

With this outline you can store individual pizzas in an array(Pizza pizzas[10]) and print each one to a file(pizzas[2].PrintPizza(outFile)).

I would also suggest breaking out each category into a separate function:

Pizza::Item ChooseSize()
{
    Pizza::Item size;
    char choice = '\0';
    while (choice == '\0')
    {
        cout << "What size would you like?\n"
            << "(1) Small\n"
            << "(2) Medium\n"
            << "(3) Large\n";
        cin >> choice;
        switch (choice)
        {
        case 1:
            size.item = "Small";
            size.cost = 30;
            break;
        case 2:
            size.item = "Medium";
            size.cost = 50;
            break;
        case 3:
            size.item = "Large";
            size.cost = 70;
            break;
        default:
            cout << "Invalid choice!\n";
            choice = '\0';
            break;
        }
    }

    return size;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.