Purchase Solution

Writing a simple C++ PROGRAM (Practice)

Not what you're looking for?

Ask Custom Question

Consider a simple textual table describing the catalogues of retail stores, with a line for each product offered by a store, like

Argos Barbie 6.99
Argos PS2 159.99
Hamleys Barbie 16.99

Each line consists of three words: a vendor code, a product code and the price of that product from that vendor (a floating point number).

Define a class to hold the catalogue record.

Write a function to read a series of catalogue records from a file into a vector of catalogue objects. You will need to use the class ifstream, which is derived from istream, like so:
#include <fstream>
...
ifstream in("catalog");
... istream operations ...

The constructor opens the file; you can then test in to see whether it succeeded.

Write a main program that reads from standard input a series of lines describing orders, like
Barbie 200
PS2 1
Barbie 2

where each line consists of two words: a product code (as in the catalogue file) and a requested quantity (a whole number).

For each input line, the program should produce on the standard output a line for each store stocking that product, combining the information from both records. For example, the above inputs might result in

Barbie 200 Argos 6.99
Barbie 200 Hamleys 16.99
PS2 1 Argos 159.99
Barbie 2 Argos 6.99
Barbie 2 Hamleys 16.99

If there are no store records for a particular vendor, there will be no output for that line.

Purchase this Solution

Solution Summary

Writing a simple C++ PROGRAM (Practice) is modeled.

Solution Preview

Hi,
<br> In my code (attached file) I've declared two classes: first ...

Solution provided by:
Education
  • BEng, Allahabad University, India
  • MSc , Pune University, India
  • PhD (IP), Pune University, India
Recent Feedback
  • " In question 2, you incorrectly add in the $3.00 dividend that was just paid to determine the value of the stock price using the dividend discount model. In question 4 response, it should have also been recognized that dividend discount models are not useful if any of the parameters used in the model are inaccurate. "
  • "feedback: fail to recognize the operating cash flow will not begin until the end of year 3."
  • "Answer was correct"
  • "Great thanks"
  • "Perfect solution..thank you"
Purchase this Solution


Free BrainMass Quizzes
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.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

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.

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.

Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.