Function declares a groceryitem object


Discuss the below:

Q: A) Define a class named GroceryItem. Include private fields that hold an item's stock number, price, quantity in stock, and total value. Write three public functions that each set one of the three fields, based on user keyboard input. The function that sets the stock number requires the user to enter exactly four digits; continue to prompt the user until a valid stock number is entered. Include a private function that calculates the GroceryItem's value field (price times quantity in stock) within the same function that accepts the quantity in stock input. Write a function that displays a GroceryItem's values. Finally, write a main() function that declares a GroceryItem object, assigns values to its fields, and uses the display function.

B) Write a main() function that declares an array of 10 GroceryItem objects. Assign values to all 10 items and display them.

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Function declares a groceryitem object
Reference No:- TGS01937906

Now Priced at $20 (50% Discount)

Recommended (94%)

Rated (4.6/5)