Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8156655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:01:18+00:00 2026-06-06T17:01:18+00:00

Assignment: Write a C++ program to read the menu information from menu.txt. First letter

  • 0

Assignment:
Write a C++ program to read the menu information from menu.txt. First letter in item code specifies whether it is an appetizer (A), entrée (E), dessert (D) or beverage (S).

A1 Bruschetta 5.29
A2 Caprese_Flatbread 6.10
A3 Artichoke-Spinach_Dip 3.99
A4 Lasagna_Fritta 4.99
A5 Mozzarella_Fonduta 5.99
E1 Lasagna_Classico 6.99
E2 Capellini_Pomodoro 7.99
E3 Eggplant_Parmigiana 8.99
E4 Fettuccine_Alfredo 7.49
E5 Tour_of_Italy 14.99
D1 Tiramisu 2.99
D2 Zeppoli 2.49
D3 Dolcini 3.49
S1 Soda 1.99
S2 Bella_Limonata 0.99
S3 Berry_Acqua_Fresca 2.88

then prompt the user for the orders. For each order, you should compute & output the total amount. Items may be listed in any order in each line.

A1 E1 D1 S1
S2 D3 E4 A4
E3 E5 A2 A4 S2 S1 D2 D2 E2
X

Once the user enters “X”, program should output the most popular appetizer, entrée, dessert, beverage. If there is a tie, you can output any one of them.

The problem I’m having is taking the input (for example, A1) and then parsing the array for the appropriate item and location in the array (for example, A1 would be test2[1], E1 would hopefully be test2[5]). I know the arrays are populated correctly. What I’m trying to use to search the array is :

for(int l = 0; l<SIZE; l++)
{   //I get an operator error every time here       
    if(s == (test2[l]))
    {   //Just a test to see if I am pulling 
        //any information                   
        cout << test2[l].getCode() << endl;
    }           
}   

Test was was instantiated as MenuItem test2[SIZE].

When I try to use the above method I always the error

no match for ‘operator==’ in ‘s == test2[l]’

Below is my MenuItem.h:

#ifndef MENUITEM_H
#define MENUITEM_H
#include <iostream>
#include <string>

using namespace std;

class MenuItem
{
private:
string code;
string name;
double price;

public:
MenuItem(string mcode = "", string mname = "", double mprice = 0);
~MenuItem();
string getCode() const { return code; }
string getName() const { return name; }
double getPrice() const { return price; }

void setCode(string mcode){ code = mcode; }
void setName(string mname){ name = mname; }
void setPrice(double mprice)  { price = mprice; }
};
#endif

Thanks for any help and input.

Sincerely,

Jason

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T17:01:19+00:00Added an answer on June 6, 2026 at 5:01 pm

    I am wondering what is the type of the variable s in the following code:

    if(s == (test2[l]))
    

    Is s a string containing the user’s input eg. “A1” ?
    Or is s a MenuItem object?

    If it is a string, then the condition would simply be

    if(s == test[l].getCode())
    

    If s is a MenuItem object, then you should implement operator== for MenuItem objects

    It’s signature might look something like this:

    bool operator== (const MenuItem&, const MenuItem&);
    

    and the implementation would involve checking if the two MenuItem objects have the same code, name and price.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my assembly language class, our first assignment was to write a program to
Current assignment needs me to write a program to read a file with instructions
I have the following assignment: Write a complete 8086 program to perform the calculator
I have been asked to write a program using python for an assignment. I
i was given an assignment . Write a program to simulate job scheduling in
Recently for a programming class, we were given the assignment to write a program
Here is the assignment verbatim: 1.) Write a Java program that is a TCP
for an assignment in my Java class I'm supposed to write a program for
I was given an assignment to write a program to print only even numbers
As the title says, I need to write a small program to read data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.