Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

This is in C++.

Given a ListItem class, complete main() using the built-in list type to create a linked list called shoppingList. The program should read items from input (ending with -1), adding each item to shoppingList, and output each item in shoppingList using the PrintNodeData() function.

EX INPUT

milk

bread

eggs

waffles

cereal

-1

Ex OUTPUT

milk

bread

eggs

waffles

cereal

 

main.cpp

#include "ListItem.h"
#include <string>
#include <list>
#include <iostream>

using namespace std;

int main (int argc, char* argv[]) {
// TODO: Declare a list called shoppingList of type ListItem

string item;

// TODO: Read inputs (items) and add them to the shoppingList list
// Read inputs until a -1 is input


// TODO: Print the shoppingList list using the PrintNodeData() function

return 0;
}

 

ListItem.h (marked as read only)

#ifndef LISTITEMH
#define LISTITEMH

#include <string>

using namespace std;

class ListItem {
public:
ListItem();

ListItem(string itemInit);

// Print this node
void PrintNodeData();

private:
string item;
};

#endif

 

ListItem.cpp (read only)

#include "ListItem.h"
#include <iostream>

ListItem::ListItem() {
item = "";
}

ListItem::ListItem(string itemInit) {
item = itemInit;
}

// Print this node
void ListItem::PrintNodeData() {
cout << item << endl;
}

 

 

Thank you

Expert Solution
Check Mark
Still need help?
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

why could you use while(true) without setting a boolean to true?

Solution
Bartleby Expert
by Bartleby Expert
SEE SOLUTION
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

why could you use while(true) without setting a boolean to true?

Solution
Bartleby Expert
by Bartleby Expert
SEE SOLUTION
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education

Expert Answers to Latest Homework Questions

Q: Compute (7^ (25)) mod 11 via the algorithm for modular exponentiation.
Q: Prove that the sum of the degrees in the interior angles of any convex polygon with n ≥ 3 sides is…
Q: Answer the following questions about rational and irrational numbers.1. Prove or disprove: If a and…
Q: Prove the following using structural induction: For any rooted binary tree T the number of vertices…
Q: (a) Prove that if p is a prime number and p|k^2 for some integer k then p|k.(b) Using Part (a),…
Q: Provide a context-free grammar for the language {a^ (i) b^ (j) c^ (k) | i, j, k ∈ N, i = j or i =…
Q: Primary, Secondary, and Tertiary Alcohols O-H O-H O-H R₁-C-H R₁-C-H R₁-C-R₁ H R₂ R₂ Primary Alcohol…
Q: Complete the reaction    hand written please
Q: Blood (HD = 0.45 in large diameter tubes) is forced through hollow fiber tubes that are 20 µm in…
Q: Complete the reaction    hand written please
Q: Complete the following equations    hand written please
Q: engineered constructs that consist of hollow fibers are acting as synthetic capillaries, around…
Q: Complete the following equations please   hand written please
Q: Using the Nernst equation to calculate nonstandard cell voltage A galvanic cell at a temperature of…
Q: Calculating standard reaction free energy from standard reduction... Using standard reduction…
Q: Calculating the pH of a weak base titrated with a strong acid An analytical chemist is titrating…
Q: please find the answers for the yellows boxes using the information and the picture below
Q: Consider the function f(x) = x²-1. (a) Find the instantaneous rate of change of f(x) at x=1 using…
Q: 1. The graph of ƒ is given. Use the graph to evaluate each of the following values. If a value does…
Q: A marketing agency wants to determine whether different advertising platforms generate significantly…
Q: A company found that the daily sales revenue of its flagship product follows a normal distribution…