here is the program exercise:
Write a program to help a local restaurant automate its breakfast billing system. The program should do the following:
a. Show the customer the different breakfast items offered by the restaurant.
b. Allow the customer to select more than one item from the menu.
c. Calculate and print the bill. Assume that the restaurant offers the following breakfast items (the price of each item is shown to the right of the item):
Plain Egg $1.45 Bacon and Egg $2.45 Muffin $0.99 French Toast $1.99 Fruit Basket $2.49 Cereal $0.69 Coffee $0.50 Tea $0.75
Use an array, menuList, of the struct menuItemType, as defined in Programming Exercise 3. Your program must contain at least the following functions:
• Function getData: This function loads the data into the array menuList. • Function showMenu: This function shows the different items offered by the restaurant and tells the user how to select the items. • Function printCheck: This function calculates and prints the check. (Note that the billing amount should include a 5% tax.)

here is my code:

#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>

using namespace std;


struct menuItemType
{
    string itemName;
    double itemCost;
};

void getData(ifstream& in, menuItemType menuList[]);
void showMenu(menuItemType menuList[]);
void printCheck(menuItemType menuList[]);

int main()
{
        cout << "\t\tWelcome to Johnny's Restaurant." << endl;
        cout << endl;

        cout<< "What would you like for breakfast?" << endl;
        cout << endl;

    string name;
    double price = 0.0;

    char dollar = char();


    cout << setprecision(2) << fixed << showpoint << endl;

    ifstream in;
    in.open("menu.txt");
    menuItemType menuList[8];

    getData(in, menuList);
    showMenu(menuList);
    printCheck(menuList);



    return 0;
}

void getData(ifstream& in, menuItemType menuList[])
{
    char temp = char();
    int i = 0;


    while (!in.eof())
    {
        in.get(temp);

        if (temp != '$')
            menuList[i].itemName = menuList[i].itemName + temp;
        else
        {
            in >> menuList[i].itemCost;
            ++i;
        }
    }
}

void showMenu(menuItemType menuList[])
{
    int choice = 0;
    double total = 0.0;
    int qty = 0;

    for (int i = 0; i < 8; i++)
    {
        cout << menuList[i].itemName << " $" << menuList[i].itemCost << endl;
    }
    cout << "Select your Item/Items: ";
    cin >> choice;

    if (choice > 0)
    {
        cout << "Enter the Quantity you Want to Order: ";
        cin >> qty;

        if (choice == 1)
        {
            cout << setprecision(0) << qty << " " << menuList[choice - 1].itemName << " " << setprecision(2) << menuList[choice - 1].itemCost << endl;
            total = total + (menuList[choice - 1].itemCost * qty) + (menuList[choice - 1].itemCost * qty * .05);
            cout << "Your Total is : "<<total <<"$"<< endl;
        }

        if (choice == 2)
        {
            cout << setprecision(0) << qty << " " << menuList[choice - 1].itemName << " " << setprecision(2) << menuList[choice - 1].itemCost << endl;
            total = total + (menuList[choice - 1].itemCost * qty) + (menuList[choice - 1].itemCost * qty * .05);
            cout << "Your Total is : " << total << "$" << endl;
        }

        if (choice == 3)
        {
            cout << setprecision(0) << qty << " " << menuList[choice - 1].itemName << " " << setprecision(2) << menuList[choice - 1].itemCost << endl;
            total = total + (menuList[choice - 1].itemCost * qty) + (menuList[choice - 1].itemCost * qty * .05);
            cout << "Your Total is : " << total << "$" << endl;
        }

        if (choice == 4)
        {
            cout << setprecision(0) << qty << " " << menuList[choice - 1].itemName << " " << setprecision(2) << menuList[choice - 1].itemCost << endl;
            total = total + (menuList[choice - 1].itemCost * qty) + (menuList[choice - 1].itemCost * qty * .05);
            cout << "Your Total is : " << total << "$" << endl;
        }

        if (choice == 5)
        {
            cout << setprecision(0) << qty << " " << menuList[choice - 1].itemName << " " << setprecision(2) << menuList[choice - 1].itemCost << endl;
            total = total + (menuList[choice - 1].itemCost * qty) + (menuList[choice - 1].itemCost * qty * .05);
            cout << "Your Total is : " << total << "$" << endl;
        }

        if (choice == 6)
        {
            cout << setprecision(0) << qty << " " << menuList[choice - 1].itemName << " " << setprecision(2) << menuList[choice - 1].itemCost << endl;
            total = total + (menuList[choice - 1].itemCost * qty) + (menuList[choice - 1].itemCost * qty * .05);
            cout << "Your Total is : " << total << "$" << endl;
        }


        if (choice == 7)
        {
            cout << setprecision(0) << qty << " " << menuList[choice - 1].itemName << " " << setprecision(2) << menuList[choice - 1].itemCost << endl;
            total = total + (menuList[choice - 1].itemCost * qty) + (menuList[choice - 1].itemCost * qty * .05);
            cout << "Your Total is : " << total << "$" << endl;

        }
    }


    else
    {
        cout << "Order has ended!" << endl;
    }
}

void printCheck(menuItemType menuList[])

{

    double total = 0.0;
    int i = 0;

    int choice;

    int qty;

    cout << endl;

    cout << "     ================================== " << endl;
    cout << "               R E C E I P T !          " << endl;
    cout << "     ================================== " << endl;
    cout << "       WELCOME TO JOHNNY'S RESTAURANT   " << endl;
    cout << "     ================================== " << endl;
    cout << endl;

    //for (int i = 0; i < 8; i++)
    //total = total + (menuList[choice - 1].itemCost * qty) + (menuList[choice - 1].itemCost * qty * .05);
        cout << "     TOTAL                  $ " << total << endl;
}

What part of your program do you need help with?

commented: the print check part +0

The print part!!!!

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.