Question

In: Computer Science

C++ Linkedlist Create a food menu so the customer can see what we are selling, if...

C++ Linkedlist

Create a food menu so the customer can see what we are selling, if the users place order that not on the menu, prompt the users to enter again. Food code and food must be matched when users enter.

Solutions

Expert Solution

Here is the solution to your question. I tried my best to solve your doubt, however, if you find it is not as good as expected by you. Please do write your further doubts regarding this question in the comment section, I will try to resolve your doubts regarding the submitted solution as soon as possible.

Please give proper indentation as shown in the screenshot

If you think, the solution provided by me is helpful to you please do an upvote.

Either you forget to upload some files or you have incomplete question. However based on your provided information that might help you:

#include<iostream>

using namespace std;
class Food
{
public:
    int code;
    string name;
    Food* next;
};
class Menu:public Food
{
 
    Food *first,*last;
public:
    Menu()
    {
        first=NULL;
        last=NULL;
    }
    void insert(int fcode,string fname);
    void search();
};

void Menu::insert(int fcode,string fname)
{
    Food *prev,*cur;
    prev=NULL;
    cur=first;
    int count=1,pos,ch,n;
    Food *temp=new Food;
    temp->code=fcode;
    temp->name=fname;
    temp->next=NULL;
    temp->next=first;
    first=temp;
}
void Menu::search()
{
    int value,pos=0;
    bool flag=false;
    if(first==NULL)
    {
        cout<<"Menu is Empty";
        return;
    }
    cout<<"Enter the Food code to be Searched:";
    cin>>value;
    Food *temp;
    temp=first;
    while(temp!=NULL)
    {
        pos++;
        if(temp->code==value)
        {
            flag=true;
            cout<<"Food "<<temp->name<<" is Found at "<<pos<<" Position"<<endl;
            return;
        }
        temp=temp->next;
    }
    if(!flag)
    {
        cout<<"Food "<<value<<" not Found in the Menu, Try Again!!!"<<endl;
        this->search();
    }
}
int main()
{
    Menu m;
    
    m.insert(1,"tea");
    m.insert(2,"water");
    m.insert(3,"breakfast");
    m.insert(4,"lunch");
    m.insert(5,"dinner");

    m.search();
    return 0;
}

Related Solutions

print a menu so that the user can then order from that menu. The user will...
print a menu so that the user can then order from that menu. The user will enter each item they want until they are done with the order. At the end you will print the items the user ordered with their price and the total. Note: You will be storing your menu items (pizza, burger, hotdog, salad) and your prices (10, 7, 4, 8) in separate lists. Menu 0) pizza $10 1) burger $7 2) hotdog $4 3) salad $8...
Use C++ to create an application that provide the menu with two options TemperatureConverter_Smith.cpp MENU CONVERTER...
Use C++ to create an application that provide the menu with two options TemperatureConverter_Smith.cpp MENU CONVERTER TEMPERATURE – JAMES SMITH Convert Fahrenheit temperature to Celsius Convert Celsius temperature to Fahrenheit Exit CASE 1: Convert Fahrenheit temperature to Celsius -Display the message to ask to enter Fahrenheit degree from the keyboard -Use the following formula to convert to Celsius degree         Celsius Temperature = (Fahrenheit Temperature – 32) * 5/9 ; -Display the output as below: TemperatureConverter_Smith.cpp TEMPERATURE CONVERTER – JAMES...
Write in Java! (Not Javascript) Consider the LinkedList class we discussed in class (see the slides...
Write in Java! (Not Javascript) Consider the LinkedList class we discussed in class (see the slides for lecture 8). Add the following methods to the class and submit the completed LinkedList class. int size() which returns the size of the linked list Link getElementByIndex(int index) which returns the Link/node specified by the index. For example, getElementByIndex(0) should return the first Link, getElementByIndex(2) should return the third Link. If index is not in range, your method should return null. boolean hasDuplicate()...
We need a Stock and Bond trading application. Here is what is required: Create Menu with...
We need a Stock and Bond trading application. Here is what is required: Create Menu with the options organized as below: ******************************************************************************** A. Buy Bonds B. Sell Bonds C. Buy Stocks D. Sell Stocks E. Short Stock Sale    X. Exit Here are the steps involved. Create a char variable named menuChoice. Display the menu as described above. Prompt for the menu choice (A-E,X) (Assume the input will be uppercased). Use an IF statement to validate that the choices are...
Write a C++ code to print to the user a simple menu of a fast food...
Write a C++ code to print to the user a simple menu of a fast food restaurant. You should allow the user to select his/her preferred burgers and/or drinks and you should display the final bill to the user for payment. The user should be able to select more than one item. You should use the switch statement.
(In C++) Bank Account Program Create an Account Class Create a Menu Class Create a main()...
(In C++) Bank Account Program Create an Account Class Create a Menu Class Create a main() function to coordinate the execution of the program. We will need methods: Method for Depositing values into the account. What type of method will it be? Method for Withdrawing values from the account. What type of method will it be? Method to output the balance of the account. What type of method will it be? Method that will output all deposits made to the...
Food inspectors inspect samples of food products to see if they are safe. This can be...
Food inspectors inspect samples of food products to see if they are safe. This can be thought of as a hypothesis test with the following hypotheses. H0: the food is safe Ha: the food is not safe The following is an example of what type of error? The sample suggests that the food is safe, but it actually is not safe. type I type II not an error
We need to create basic program that will simply display a menu and allow the user...
We need to create basic program that will simply display a menu and allow the user to select one of the choices. The menu should be displayed such that each option will be numbered, as well as have one capital letter so as to indicate that either the number or the designated letter can be entered to make their choice. Once the choice is made, the sub-menu for that selection should be displayed. Colors with an odd number of letters...
I need to create a code in C++ that first has a menu animation of game...
I need to create a code in C++ that first has a menu animation of game Pacman, a score label in the map, and a bar that have the lives of pacman in the map.
Use menu based functionality and validation loops to create a new customer bonus fruit package application...
Use menu based functionality and validation loops to create a new customer bonus fruit package application for the Dirt to Dish discount produce company. The program you create will prompt the user to enter a number to select one of three bonus pack options: 1 for Apple pack 2 for Orange pack 3 for Banana pack **Use input validation to ensure a valid option has been selected before proceeding. Use variables to keep track of how many of each fruit...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT