1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
yulyashka [42]
4 years ago
12

Imagine you just left a store with a bag of groceries. You are concerned that the fragile items will not survive the trip home,

so when you reach your car, you place those items into their own bag. Using the templated version of the Bag class from Chapter 1 (one file version with header and implementation combined that is posted on Blackboard) write C++ statements that remove all the fragile items (eggs and bread) from storeBag place them into fragileBag. Print the contents of both bags using a method named displayBagContents that you added to the Bag class.
Again suppose that a bag contains strings that represent various grocery items. Write a 2 argument C++ function that removes and counts all occurrences of a given string from such a bag. Your function should return the number of items removed. Handle the possibility that the given bag is either empty or does not contain any occurrences of the given string. Print the count returned and the contents of the bag after the function executes displayBagContents member function that you added to the Bag class.
Computers and Technology
1 answer:
iogann1982 [59]4 years ago
3 0

Answer:

Explanation:

#include <iostream>

using namespace std;

#include <iostream> // For cout and cin

#include <string>   // For string objects

#include "Bag.h"    // For ADT bag

using namespace std;

int main()

{

int y=0;

string clubs[] = { "eggs", "eggs", "eggs", "orange", "bread", "bread" };

Bag<string> grabBag;

Bag<string> fragileBag;

for (int x = 0; x < 6; x++) {

grabBag.add(clubs[x]);

}

int count = 0;

for (int q = 0; q < 6 ; q++)

{

if (clubs[y] == "eggs" || clubs[y] == "bread") {

fragileBag.add(clubs[y]);

if(grabBag.remove("eggs")){

   ++count;

}

}

y++;

}

cout << "fragile bag contains:" << endl;

fragileBag.displayBagContents();

cout << "grocery bag contains:" << endl;

grabBag.displayBagContents();

cout << "Number of items removed from grocery bag : " << count<<endl;

return 0;

};

You might be interested in
Differences of a desktop computer and a laptop
Ilya [14]

Answer:

Desktop can't move easily, not portable. Laptop very portable.

Explanation:

6 0
3 years ago
Identity theft, where people steal personal information, continues to be a problem for consumers and businesses. Assume that you
svetlana [45]

Answer:

Secure the personal information with complex multi-factor authentication and configure intrusion detection and prevention and a firewall.

Explanation:

Multi-factor authentication is a method of securing a client's personal information from the client's side to the data centre. It uses more than one security processes not policies. There key be three authentications process like a password, security token and biometrics or two authentications like password and biometrics or token.

The firewall and intrusion detection and prevention are vulnerability preventive method to detect and stop cyber attacks.

5 0
3 years ago
What is the term for a media piece that is ineligible for protection by copyright laws,
Nataliya [291]

Answer: D. Public domain

Explanation:

Hi, the term Public domain is applied to works of authorship that are ineligible for protection by copyright laws, because the copyright has expired or it was never copyrighted in the first place.

Public domain may vary in different countries and jurisdictions, for example; a media piece may be protected by copyright in one specific country, and be public domain in other countries.

Feel free to ask for more if needed or if you did not understand something.

6 0
4 years ago
When you code a column list in an INSERT statement, you can omit columns with default values and columns that allow ____________
stiks02 [169]

Answer:

NULL is the correct answer of this question.

Explanation:

The insert statement is used for inserting a column list into the database this statement is an under Data Manipulation language.When we insert any column into the database there is always a null value stored.

  • Insert statement is used to insert the data into the database .
  • To insert data following syntax is used:-

         insert into tablename (column data type).

  • When we insert any data into the database the default value is stored is bull.
6 0
3 years ago
which of the following is not an e-reader you would use as a alternative to carrying around a set of textbooks?
musickatia [10]

I have a kindle paper white that I downloaded all of my avalible textbook onto if that helps I find it much better then carrying around a bunch of textbooks
4 0
3 years ago
Other questions:
  • What is the primary purpose for a screen saver in windows?
    8·1 answer
  • What is one way to improve the upward flow of information?
    12·1 answer
  • What does f.i.r.s.t stand for in robotics
    15·1 answer
  • Match the file extensions to the file types. Some file types may be used more than once.
    11·1 answer
  • Savings accounts usually offer _________ interest rates than checking accounts. It is _________ to access your money in a saving
    10·2 answers
  • RAM IS often referred
    9·1 answer
  • Which of the following is a productivity strategy for collaboration?
    9·1 answer
  • Outside of a C program, a file is identified by its ________while inside a C program, a file is identified by a(n) ________. fil
    13·1 answer
  • [2]<br> (c) Describe how the microprocessor can determine when to sound the clock alarm.
    6·1 answer
  • personalization allows customers to modify the standard offering, such as selecting a different home page to be displayed each t
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!