0

I'am new in c++ programming.So I take another people program and I try to using array for the program fix but I don't know the syntax and I still don't understand what kind of array that will do to fix this program because I cant put like food[i+1] to print all the item in the receipt https://www.dreamincode.net/forums/topic/385630-displaying-users-inputs-in-receipt/

    #include<iostream>
    #include<iomanip>
    #include<string>
    using namespace std;
    
    void mainMenu();
    
    
    void totalCost();
    double total;     
    
    int main()
    {
        string choice;
        
        char menuOption;    
    
        mainMenu();
    do
    {
        cin >> menuOption;
        switch (menuOption)
        {
        case '1':
            choice = "Sandwich";
            total +=4.99;
            mainMenu();
            break;
        case '2':
            choice = "Soup of the Day";
            total += 2.99;
            cout << endl;
            mainMenu();
            break;
        case '3':
                        choice = "Mac and Cheese";

            total += 3.99;
            cout << endl;
            mainMenu();
        case '4':
                        choice = "Bagel with Cream Cheese";
            total += 1.99;
            cout << endl;
            mainMenu();
            break;
        
        case '5':
            cout << "Thank you for ordering!";
            cout << endl;
            totalCost();
            break;
        default:
            cout << "Please enter the number from the menu";
            cout << " you wish to add to your order, then press enter";
            cout << endl;
            mainMenu();
            break;
        }
    } while (menuOption != '5');

    cout << "\nHere is your receipt!" << endl;
    cout << choice << endl; //This should display all the choices the user selected
    cout << "Your total will be " << total << endl;
    system("PAUSE");
    return 0;
}

void mainMenu()
{
    cout << "Please select from option below";
    
    cout << "[1] - Sandwiches $4.99\n";
    cout << "[2] - Soups of the Day $2.99\n";
    cout << "[3] - Mac and Cheese $3.99\n";
    cout << "[4] - Bagel with Cream Cheese $1.99\n";
    cout << "[5] - Total your entire order when you're finished\n";
}

void totalCost()
{
    total = total;
}
  • 4
    A [good C++ book](https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list) might be more useful. – Anoop Rana May 15 '22 at 12:12

0 Answers0