Load Menu into Arrays, Print Menu, Get Order, Print Receipt

We learned about arrays for less than an hour and our professor wants us to write an ordering system that is divided up into several smaller functions that:

-Load the menu
-Print the menu
-Get the order from the user
-Print the receipt
-Plus smaller helper functions.
-Have arrays for the product names, prices and user orders
-These arrays should live in main and be passed to the functions

I'll be honest I just have no idea where to start. I don't know how to pass arrays into functions. Right now I only have the load menu function. My professor is at a conference all week so I'm at the mercy of the internet. Thank you.


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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <iostream>
#include <fstream>
#include <iomanip>
#include <climits>

using namespace std;

void loadMenu()
{
    double price;

    ifstream file;

    string fileName, name;

    char menuChoice;

    cout << "Which menu would you like Normal or Kids or Special? (N or K or S) ";

    cin >> menuChoice;

    menuChoice = tolower(menuChoice);

    if (menuChoice == 'k')
    {
        cout << endl;

        cout << "HERE IS THE KIDS MENU:" << endl;

        file.open("kids_menu.txt");
    }

    else if (menuChoice == 'n')
    {
        cout << endl;

        cout << "HERE IS THE NORMAL MENU:" << endl;

        file.open("normal_menu.txt");
    }

    else if (menuChoice == 's')
    {
        cout << endl;

        cout << "HERE IS THE SPECIAL MENU:" << endl;

        file.open("special_menu.txt");
    }

    getline(file, name, ',');

    file >> price;

    while (file)
    {
        name = eol_trim(name);

        cout << name << ": " << price << endl;
        
        i++;

        getline(file, name, ',');

        file >> price;
    }
}

const int MAX = 20;

int main()
{
    string productNames [i] = name;
    
    double productPrices [i] = price;
    
    cout << setprecision(2) << fixed;

    cout << "WELCOME TO BOB'S BURGERS RELOADED!" << endl;

    loadMenu();
}
Topic archived. No new replies allowed.