//main.cpp #include "Person.h" #include "Seller.h" #include "Powerseller.h" #include #include #include #include using namespace std; void printMenu(); void printSellers(list sellers); void checkSeller(list sellers); void addSeller(list sellers); void deleteSeller(list &sellers); int main() {   list sellers;   ifstream infile;   infile.open("sellers.dat");   if (!infile) {       cerr << "File could not be opened." << endl;       exit(1);   }   char type;   while (!infile.eof())    {       infile >> type;       if (type == 'S')        {         Seller* newseller = new Seller;         newseller -> read(infile);         sellers.push_back(newseller);       }                 if (type == 'P')        {         Powerseller* newpowerseller = new Powerseller;         newpowerseller -> read(infile);         sellers.push_back(newpowerseller);       }   }   infile.close();   bool done = false;   int choice;   while (!done) {       printMenu();       cin >> choice;       switch (choice) {           case 1:               printSellers(sellers);               break;           case 2:               checkSeller(sellers);               break;           case 3:               addSeller(sellers);               break;           case 4:               deleteSeller(sellers);               break;           case 5:               done = true;               break;       }   }   return 0; } void printMenu() {   cout << endl;   cout << "Menu" << endl;   cout << "1. Print information of all sellers" << endl;   cout << "2. Check information of a particular seller" << endl;   cout << "3. Add a seller to the list" << endl;   cout << "4. Remove a seller from the list" << endl;   cout << "5. Quit" << endl;   cout << "Enter your choice: "; } void printSellers(list sellers) {   for (list::iterator i = sellers.begin(); i != sellers.end(); i++)    {       (*i)->print();   } } void checkSeller(list sellers) {   string fname, lname;   cout << "Enter the seller's first name: " ;   cin >> fname;   cout << "Enter the seller's last name: " ;   cin >> lname;   bool found = false;   for (list::iterator i = sellers.begin(); i != sellers.end(); i++) {       if ((*i)->getFirstName() == fname && (*i)->getLastName() == lname)        {           found = true;           cout << "\n" << endl;           (*i)->print();       }   }   if (!found)    {       cout << "Seller not found." << endl;   } } void addSeller(list sellers)  {   string fname, lname, info, web, em, id;   int sold, item;   float rating;   cout << "Please enter the following information (enter invalid type to quit): " << "\n";     cout << "Is the seller a (S)eller or (P)ower Seller? ";   cin >> info;   if (info == "S")    {       cout << "first name: " << endl;       cin >> fname;       cout << "last name: " << endl;       cin >> lname;            cout << "User ID: " << endl;       cin >> id;       cout << "Email Address: " << endl;       cin >> em;       //Email Address:       cout << "Average Star Rating: " << endl;       cin >> rating;       cout << "Total Items sold: " << endl;       cin >> item;            cout << "The new Power Seller has been added.  Returning to Seller Management..." << endl;       Seller* newseller = new Seller;       newseller -> read(cin);       sellers.push_back(newseller);   }    if (info == "P")   {     cout << "first name: " << endl;     cin >> fname;     cout << "last name: " << endl;     cin >> lname;     cout << "User ID: " << endl;     cin >> id;     cout << "Email Address:" << endl;     cin >> em;     //Email Address:     cout << "Average Star Rating: " << endl;     cin >> rating;     cout << "Total Items sold: " << endl;     cin >> item;     cout << "Website Address: " << endl;     cin >> web;     cout << "Current year products Sold: " << endl;     cin >> sold;     Powerseller* newpowerseller = new Powerseller;     newpowerseller -> read(cin);     sellers.push_back(newpowerseller);     //for (list::iterator i = sellers.begin(); i != sellers.end(); i++)     //{        //Powerseller* newpowerseller = new Powerseller;        //newpowerseller -> read(cin);        //sellers.push_back(newpowerseller);        //break;     //}   } } void deleteSeller(list &sellers) {   string fname, lname;   cout << "Enter the seller's first name: ";   cin >> fname;   cout << "Enter the seller's last name: ";   cin >> lname;   bool found = false;   for (list::iterator i = sellers.begin(); i != sellers.end(); i++) {       if ((*i)->getFirstName() == fname && (*i)->getLastName() == lname) {           found = true;           sellers.erase(i);           break;       }   }   if (!found)    {       cout << "Seller not found." << endl;   } }   My add function doesn't return to the menu. Can you help me out?

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

//main.cpp

#include "Person.h"
#include "Seller.h"
#include "Powerseller.h"
#include <iostream>
#include <list>
#include <fstream>
#include <string>

using namespace std;

void printMenu();
void printSellers(list<Seller*> sellers);
void checkSeller(list<Seller*> sellers);
void addSeller(list<Seller*> sellers);
void deleteSeller(list<Seller*> &sellers);

int main() {
  list<Seller*> sellers;
  ifstream infile;
  infile.open("sellers.dat");
  if (!infile) {
      cerr << "File could not be opened." << endl;
      exit(1);
  }
  char type;
  while (!infile.eof()) 
  {
      infile >> type;
      if (type == 'S') 
      {
        Seller* newseller = new Seller;
        newseller -> read(infile);
        sellers.push_back(newseller);
      } 
        
      if (type == 'P') 
      {
        Powerseller* newpowerseller = new Powerseller;
        newpowerseller -> read(infile);
        sellers.push_back(newpowerseller);
      }
  }
  infile.close();
  bool done = false;
  int choice;
  while (!done) {
      printMenu();
      cin >> choice;
      switch (choice) {
          case 1:
              printSellers(sellers);
              break;
          case 2:
              checkSeller(sellers);
              break;
          case 3:
              addSeller(sellers);
              break;
          case 4:
              deleteSeller(sellers);
              break;
          case 5:
              done = true;
              break;
      }
  }
  return 0;
}

void printMenu() {
  cout << endl;
  cout << "Menu" << endl;
  cout << "1. Print information of all sellers" << endl;
  cout << "2. Check information of a particular seller" << endl;
  cout << "3. Add a seller to the list" << endl;
  cout << "4. Remove a seller from the list" << endl;
  cout << "5. Quit" << endl;
  cout << "Enter your choice: ";
}

void printSellers(list<Seller*> sellers) {
  for (list<Seller*>::iterator i = sellers.begin(); i != sellers.end(); i++) 
  {
      (*i)->print();
  }
}

void checkSeller(list<Seller*> sellers) {
  string fname, lname;
  cout << "Enter the seller's first name: " ;
  cin >> fname;
  cout << "Enter the seller's last name: " ;
  cin >> lname;
  bool found = false;
  for (list<Seller*>::iterator i = sellers.begin(); i != sellers.end(); i++) {
      if ((*i)->getFirstName() == fname && (*i)->getLastName() == lname) 
      {
          found = true;
          cout << "\n" << endl;
          (*i)->print();
      }
  }
  if (!found) 
  {
      cout << "Seller not found." << endl;
  }
}

void addSeller(list<Seller*> sellers) 
{
  string fname, lname, info, web, em, id;
  int sold, item;
  float rating;
  cout << "Please enter the following information (enter invalid type to quit): " << "\n";
    cout << "Is the seller a (S)eller or (P)ower Seller? ";
  cin >> info;
  if (info == "S") 
  {
      cout << "first name: " << endl;
      cin >> fname;
      cout << "last name: " << endl;
      cin >> lname;
    
      cout << "User ID: " << endl;
      cin >> id;

      cout << "Email Address: " << endl;
      cin >> em;
      //Email Address:
      cout << "Average Star Rating: " << endl;
      cin >> rating;

      cout << "Total Items sold: " << endl;
      cin >> item;
    
      cout << "The new Power Seller has been added.  Returning to Seller Management..." << endl;
      Seller* newseller = new Seller;
      newseller -> read(cin);
      sellers.push_back(newseller);
  }
 
 if (info == "P") 
 {
    cout << "first name: " << endl;
    cin >> fname;
    cout << "last name: " << endl;
    cin >> lname;
    cout << "User ID: " << endl;
    cin >> id;

    cout << "Email Address:" << endl;
    cin >> em;
    //Email Address:
    cout << "Average Star Rating: " << endl;
    cin >> rating;

    cout << "Total Items sold: " << endl;
    cin >> item;
    cout << "Website Address: " << endl;
    cin >> web;
    cout << "Current year products Sold: " << endl;
    cin >> sold;
    Powerseller* newpowerseller = new Powerseller;
    newpowerseller -> read(cin);
    sellers.push_back(newpowerseller);
    //for (list<Seller*>::iterator i = sellers.begin(); i != sellers.end(); i++)
    //{
       //Powerseller* newpowerseller = new Powerseller;
       //newpowerseller -> read(cin);
       //sellers.push_back(newpowerseller);
       //break;
    //}
  }
}

void deleteSeller(list<Seller*> &sellers) {
  string fname, lname;
  cout << "Enter the seller's first name: ";
  cin >> fname;
  cout << "Enter the seller's last name: ";
  cin >> lname;
  bool found = false;
  for (list<Seller*>::iterator i = sellers.begin(); i != sellers.end(); i++) {
      if ((*i)->getFirstName() == fname && (*i)->getLastName() == lname) {
          found = true;
          sellers.erase(i);
          break;
      }
  }
  if (!found) 
  {
      cout << "Seller not found." << endl;
  }
}

 

My add function doesn't return to the menu. Can you help me out?

Menu
1. Print information of all sellers
2. Check information of a particular seller
3. Add a seller to the list
4. Remove a seller from the list
5. Quit
Enter your choice: 3
Please enter the following information (enter invalid type to qui
t):
Is the seller a (S)eller or (P)ower Seller? S
first name:
Luke
last name:
River
User ID:
LR89
Email Address:
LR89@goggle.com
Average Star Rating:
5
Total Items sold:
455
The new Power Seller has been added. Returning to Seller Managem
ent...
0
Transcribed Image Text:Menu 1. Print information of all sellers 2. Check information of a particular seller 3. Add a seller to the list 4. Remove a seller from the list 5. Quit Enter your choice: 3 Please enter the following information (enter invalid type to qui t): Is the seller a (S)eller or (P)ower Seller? S first name: Luke last name: River User ID: LR89 Email Address: LR89@goggle.com Average Star Rating: 5 Total Items sold: 455 The new Power Seller has been added. Returning to Seller Managem ent... 0
Please choose from the following menu:
1. Print all seller information
2. Check information of one seller
3. Add a seller
4. Remove a seller
5. Quit
Enter your choice: 3
Please enter the following information (enter invalid type to quit):
Is the seller a (S)eller or (P)ower Seller? S
First name: Angela
Last name: Thomas
User ID: angthomas
Email Address: angela.thomas@bellsouth.com
Average Star Rating: 3.7
Total Items sold: 380
The new Seller has been added. Returning to Seller management...
Please choose from the following menu:
1. Print all seller information
2. Check information of one seller
3. Add a seller
4. Remove a seller
5. Quit
Transcribed Image Text:Please choose from the following menu: 1. Print all seller information 2. Check information of one seller 3. Add a seller 4. Remove a seller 5. Quit Enter your choice: 3 Please enter the following information (enter invalid type to quit): Is the seller a (S)eller or (P)ower Seller? S First name: Angela Last name: Thomas User ID: angthomas Email Address: angela.thomas@bellsouth.com Average Star Rating: 3.7 Total Items sold: 380 The new Seller has been added. Returning to Seller management... Please choose from the following menu: 1. Print all seller information 2. Check information of one seller 3. Add a seller 4. Remove a seller 5. Quit
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY