Purchase Solution

GroceryItem

Not what you're looking for?

Ask Custom Question

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.

Attachments
Purchase this Solution

Solution Summary

Define a class named GroceryItem

Solution Preview

Please try the following program. There are three files including header file, cpp file and the main
file. You have to create a Win32 console application project to run the program. There will be 10 objects of groceryitems, but the item number is always 4 digit number, if 4 digit number is not entered, it will keep asking for item number. For every item there is price and quantity, price is integer value for simplicity and when all 10 items are entered, the program displays 10 items with corresponding item number and total value for particular ...

Purchase this Solution


Free BrainMass Quizzes
Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

Basic Networking Questions

This quiz consists of some basic networking questions.

Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.