#include #include using namespace std; /* This program declares a class called Inventory that has itemnNumber (which contains the id number of a product) and numOfItem (which contains the quantity on hand of the corresponding product)as private data members. The program will read these values from a file and store them in an array of objects (of type Inventory). It will then print these values to the screen. Example: Given the following data file: 986 8 432 24 This program reads these values into an array of objects and prints the following: Item number 986 has 8 items in stock Item number 432 has 24 items in stock   */ const NUMOFPROD = 10; // This holds the number of products a store sells class Inventory { public: void getId(int item); // This puts item in the private data member // itemNumber of the object that calls it. void getAmount(int num); // This puts num in the private data member // numOfItem of the object that calls it. }; void display(); // This prints to the screen // the value of itemNumber and numOfItem of the // object that calls it. // This is an id number of the product // This is the number of items in stock private: int itemNumber; int numOfItem; int main() { ifstream infile; infile.open("Inventory.dat"); // Input file to read values into array // Fill in the code that defines an array of objects of class Inventory // called products. The array should be of size NUMOFPROD int pos; int id; int total; // loop counter // variable holding the id number // variable holding the total for each id number // Fill in the code that will read inventory numbers and number of items // from a file into the array of objects. There should be calls to both // getId and getAmount member functions somewhere in this code. // Example: products[pos].getId(id); will be somewhere in this code // Fill in the code to print out the values (itemNumber and numOfItem) for // each object in the array products. // This should be done by calling the member function display within a loop return 0; } // Write the implementations for all the member functions of the class. Exercise 1: Complete the program by giving the code explained in the com- mands in bold. The data file is as follows:   *****Photo*****

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

#include <iostream>

#include <fstream>

using namespace std;

/*

This program declares a class called Inventory that has itemnNumber (which contains the id number of a product) and numOfItem (which contains the quantity on hand of the corresponding product)as private data members.
The program will read these values from a file and store them in an

array of objects (of type Inventory). It will then print these values to the screen.

Example: Given the following data file:

986 8

432 24


This program reads these values into an array of objects and prints the following:

Item number 986 has 8 items in stock

Item number 432 has 24 items in stock

 

*/

const NUMOFPROD = 10; // This holds the number of products a store sells

class Inventory {
public:

void getId(int item); // This puts item in the private data member // itemNumber of the object that calls it.

void getAmount(int num); // This puts num in the private data member // numOfItem of the object that calls it.

};

void display();

// This prints to the screen
// the value of itemNumber and numOfItem of the // object that calls it.

// This is an id number of the product // This is the number of items in stock

private:

int itemNumber;

int numOfItem;

int main() {

ifstream infile;

infile.open("Inventory.dat");

// Input file to read values into array

// Fill in the code that defines an array of objects of class Inventory // called products. The array should be of size NUMOFPROD

int pos;

int id;

int total;

// loop counter
// variable holding the id number
// variable holding the total for each id number

// Fill in the code that will read inventory numbers and number of items // from a file into the array of objects. There should be calls to both

// getId and getAmount member functions somewhere in this code.
// Example: products[pos].getId(id); will be somewhere in this code

// Fill in the code to print out the values (itemNumber and numOfItem) for

// each object in the array products.
// This should be done by calling the member function display within a loop

return 0; }

// Write the implementations for all the member functions of the class.

Exercise 1: Complete the program by giving the code explained in the com- mands in bold. The data file is as follows:

 

*****Photo*****

// Write the implementations for all the member functions of the class.
Exercise 1: Complete the program by giving the code explained in the com-
mands in bold. The data file is as follows:
986 8
432 24
132 100
Lesson 13B
123 89
329 50
503 30
783 78
822 32
233 56
322 74
The output should be as follows:
Item number 986 has 8 items in stock
Item number 432 has 24 items in stock
Item number 132 has 100 items in stock
Item number 123 has 89 items in stock
Item number 329 has 50 items in stock
Item number 503 has 30 items in stock
Item number 783 has 78 items in stock
Item number 822 has 32 items in stock
Item number 233 has 56 items in stock
Item number 322 has 74 items in stock
Transcribed Image Text:// Write the implementations for all the member functions of the class. Exercise 1: Complete the program by giving the code explained in the com- mands in bold. The data file is as follows: 986 8 432 24 132 100 Lesson 13B 123 89 329 50 503 30 783 78 822 32 233 56 322 74 The output should be as follows: Item number 986 has 8 items in stock Item number 432 has 24 items in stock Item number 132 has 100 items in stock Item number 123 has 89 items in stock Item number 329 has 50 items in stock Item number 503 has 30 items in stock Item number 783 has 78 items in stock Item number 822 has 32 items in stock Item number 233 has 56 items in stock Item number 322 has 74 items in stock
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
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