Related questions
//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?
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images
- Dice_Game.cpp #include <iostream>#include "Die.h" using namespace std; // a struct for game variablesstruct GameState { int turn = 1; int score = 0; int score_this_turn = 0; bool turn_over = false; bool game_over = false; Die die;}; // declare functionsvoid display_rules();void play_game(GameState&);void take_turn(GameState&);void roll_die(GameState&);void hold_turn(GameState&); int main() { display_rules(); GameState game; play_game(game);} // define functionsvoid display_rules() { cout << "Dice Game Rules:\n" << "\n" << "* See how many turns it takes you to get to 20.\n" << "* Turn ends when you hold or roll a 1.\n" << "* If you roll a 1, you lose all points for the turn.\n" << "* If you hold, you save all points for the turn.\n\n";} void play_game(GameState& game) { while (!game.game_over) { take_turn(game); } cout << "Game...arrow_forward6. sum_highest_five This function takes a list of numbers, finds the five largest numbers in the list, and returns their sum. If the list of numbers contains fewer than five elements, raise a ValueError with whatever error message you like. Sample calls should look like: >>> sum_highest_five([10, 10, 10, 10, 10, 5, -17, 2, 3.1])50>>> sum_highest_five([5])Traceback (most recent call last): File "/usr/lib/python3.8/idlelib/run.py", line 559, in runcode exec(code, self.locals) File "<pyshell#44>", line 1, in <module> File "/homework/final.py", line 102, in sum_highest_five raise ValueError("need at least 5 numbers")ValueError: need at least 5 numbersarrow_forward#ifndef LLCP_INT_H#define LLCP_INT_H #include <iostream> struct Node{ int data; Node *link;};void DelOddCopEven(Node*& headPtr);int FindListLength(Node* headPtr);bool IsSortedUp(Node* headPtr);void InsertAsHead(Node*& headPtr, int value);void InsertAsTail(Node*& headPtr, int value);void InsertSortedUp(Node*& headPtr, int value);bool DelFirstTargetNode(Node*& headPtr, int target);bool DelNodeBefore1stMatch(Node*& headPtr, int target);void ShowAll(std::ostream& outs, Node* headPtr);void FindMinMax(Node* headPtr, int& minValue, int& maxValue);double FindAverage(Node* headPtr);void ListClear(Node*& headPtr, int noMsg = 0); // prototype of DelOddCopEven of Assignment 5 Part 1 #endifarrow_forward
- Create pseudocode for the following #include <iostream> #include <string> #include <cstdlib> #include <ctime> using namespace std; char water[10][10] = {{'~','~','~','~','~','~','~','~','~','~'},{'~','~','~','~','~','~','~','~','~','~'},{'~','~','~','~','~','~','~','~','~','~'},{'~','~','~','~','~','~','~','~','~','~'},{'~','~','~','~','~','~','~','~','~','~'},{'~','~','~','~','~','~','~','~','~','~'},{'~','~','~','~','~','~','~','~','~','~'},{'~','~','~','~','~','~','~','~','~','~'},{'~','~','~','~','~','~','~','~','~','~'},{'~','~','~','~','~','~','~','~','~','~'}}; void createBoard(int &numShip); void promptCoords(int& userX, int &userY); void shipGen(int shipX[] ,int shipY[], int &numShip); void testCoords(int &userX, int &userY, int shipX[], int shipY[], int &numShip, int& victory); void updateBoard();arrow_forward>> IN C PROGRAMMING LANGUAGE ONLY << COPY OF DEFAULT CODE, ADD SOLUTION INTO CODE IN C #include <stdio.h>#include <stdlib.h>#include <string.h> #include "GVDie.h" int RollSpecificNumber(GVDie die, int num, int goal) {/* Type your code here. */} int main() {GVDie die = InitGVDie(); // Create a GVDie variabledie = SetSeed(15, die); // Set the GVDie variable with seed value 15int num;int goal;int rolls; scanf("%d", &num);scanf("%d", &goal);rolls = RollSpecificNumber(die, num, goal); // Should return the number of rolls to reach total.printf("It took %d rolls to get a \"%d\" %d times.\n", rolls, num, goal); return 0;}arrow_forwardC++ programming task. main.cc file: #include <iostream>#include <map>#include <vector> #include "plane.h" int main() { std::vector<double> weights{3.2, 4.7, 2.1, 5.5, 9.8, 7.4, 1.6, 9.3}; std::cout << "Printing out all the weights: " << std::endl; // ======= YOUR CODE HERE ======== // 1. Using an iterator, print out all the elements in // the weights vector on one line, separated by spaces. // Hint: see the README for the for loop syntax using // an iterator, .begin(), and .end() // ========================== std::cout << std::endl; std::map<std::string, std::string> abbrevs{{"AL", "Alabama"}, {"CA", "California"}, {"GA", "Georgia"}, {"TX", "Texas"}}; std::map<std::string, double> populations{ {"CA", 39.2}, {"GA", 10.8}, {"AL", 5.1}, {"TX", 29.5}}; std::cout <<...arrow_forward
- #include <iostream> #include <cmath> #include <iomanip> using namespace std; int calc_qty(int qty); void receipt( int qty, int qty2); int calc_qty(int qty); void coffee_size(int qty, int size, int choice, int qty2); void slices(); void beanounces(); int main() { int qty = 0, order = 0, size = 0, qty2 = 0; receipt (qty,qty2); calc_qty (qty); do { //displays the menu cout<<" Please select an item on the menu you would like to buy."<<endl; cout<<"Enter 1 for Coffee\n"<<"Enter 2 for cheese cake\n"<<"Enter 3 for coffee beens\n"<<endl; cin>>choice; } switch (choice) { case 1: coffee_size(qty, size, order, qty2); break; case 2: slices(); break; case 3: beanounces(); break; case 4: cout<<"Enjoy your day"<<endl;...arrow_forwardplease use DEQUE #include <iostream>#include <string>#include <deque> using namespace std; const int AIRPORT_COUNT = 12;string airports[AIRPORT_COUNT] = {"DAL","ABQ","DEN","MSY","HOU","SAT","CRP","MID","OKC","OMA","MDW","TUL"}; int main(){// define stack (or queue ) herestring origin;string dest;string citypair;cout << "Loading the CONTAINER ..." << endl;// LOAD THE STACK ( or queue) HERE// Create all the possible Airport combinations that could exist from the list provided.// i.e DALABQ, DALDEN, ...., ABQDAL, ABQDEN ...// DO NOT Load SameSame - DALDAL, ABQABQ, etc .. cout << "Getting data from the CONTAINER ..." << endl;// Retrieve data from the STACK/QUEUE here } Using the attached shell program (AirportCombos.cpp), create a list of strings to process and place on a STL DEQUE container. Using the provided 3 char airport codes, create a 6 character string that is the origin & destination city pair. Create all the possible...arrow_forwardC++main.cc file #include <iostream>#include <map>#include <vector> #include "bank.h" int main() { // =================== YOUR CODE HERE =================== // 1. Create a Bank object, name it anything you'd like :) // ======================================================= // =================== YOUR CODE HERE =================== // 2. Create 3 new accounts in your bank. // * The 1st account should belong to "Tuffy", with // a balance of 121ドル.00 // * The 2nd account should belong to "Frank", with // a balance of 1234ドル.56 // * The 3nd account should belong to "Oreo", with // a balance of 140ドル.12 // ======================================================= // =================== YOUR CODE HERE =================== // 3. Deactivate Tuffy's account. // ======================================================= // =================== YOUR CODE HERE =================== // 4. Call DisplayBalances to print out all *active* // account...arrow_forward
- //client.c#include "csapp.h" int main(int argc, char **argv){ int connfd; rio_t rio; connfd = Open_clientfd(argv[1], argv[2]); Rio_readinitb(&rio, connfd); char buffer[MAXLINE]; printf("Your balance is %s\n", buffer); Close(connfd); exit(0); int choice; float amount; int acc2; char buffer[MAXLINE]; rio_t rio; Rio_readinitb(&rio, connfd); while (1) { printf("\nHello welcome to the Bank Management System\n"); printf("----------------------\n"); printf("1. Check Balance\n"); printf("2. Deposit\n"); printf("3. Withdraw\n"); printf("4. Transfer\n"); printf("5. Quit\n"); printf("Enter your choice: "); Rio_writen(connfd, &choice, sizeof(int)); if (choice == 1) { printf("Your balance is %s\n", buffer); } else if (choice == 2) { printf("Enter amount to deposit: "); Rio_writen(connfd, &amount,...arrow_forwardusing accessarrow_forward#include using namespace std; struct ListNode { string data; ListNode *next; }; int main() { ListNode *p, *list; list = new ListNode; list->data = "New York"; p new ListNode; p->data = "Boston"; list->next = p; p->next = new ListNode; p->next->data = "Houston"; p->next->next = nullptr; // new code goes here Which of the following code correctly deletes the node with value "Boston" from the list when added at point of insertion indicated above? O list->next = p; delete p; O p = list->next; %3D list->next = p->next; delete p; p = list->next; list = p->next; delete p; O None of these O p = list->next; %3D list->next = p; %3D delete p;arrow_forward
- Text book imageComputer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONText book imageComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceText book imageNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Text book imageConcepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningText book imagePrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationText book imageSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY