Create an Inventory class with data members for stock number, quantity, and price, and overloaded data entry and output operators. The data entry operator function should throw: » An error message, if...



Create an Inventory class with data members for stock number, quantity, and price, and


overloaded data entry and output operators. The data entry operator function should throw:


» An error message, if the stock number is negative or higher than 999


» The quantity, if it is less than 0


» The price, if it is over $100.00


Then perform the following tasks:


a. Write a main()function that instantiates an array of five Inventory objects, and accepts


data for each. Display an appropriate error message for each exception situation. When an


exception is detected, replace all data fields with zeroes. At the end of the program, display


data fields for all five objects. Save the file as Inventory.cpp.


b. Write a main()function that instantiates an array of five Inventory objects and accepts


data for each. If an exception is thrown because of an invalid stock number, force the user


to reenter the stock number for the Inventory object. If the quantity is invalid, do nothing. If the price is in error, then set the price to 99.99. (Add a setPrice()function to the


Inventory class to accomplish this.) At the end of the program, display data fields for all


five objects. Save the file as Inventory2.cpp.


c. Write a main()function that instantiates an array of five Inventory objects and accepts


data for each. If an exception is thrown because of an invalid stock number, force the stock


number to 999; otherwise, do nothing. (Add any needed functions to the Inventory


class.) At the end of the program, display data fields for all five objects. Save the file as


Inventory3.cpp.


d. Write a main()function that instantiates an array of five Inventory objects and accepts


data for each. If any exception is thrown, stop accepting data. Display as many objects as


were entered correctly. Save the file as Inventory4.cpp.

May 19, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here