vendredi 20 novembre 2020

How would you define lines of the same type at specific points in a multi paragraph input in c++?

I'm an amateur at C++ and I'm working on this project where I have store inventory in the form of a standard text input.

Each paragraph gives the name of the store in the first line, location in the second line and the items available in that store in the following rows which has the order- item name, quantity, price. After every blank line (start of new paragraph) the next store's information is given and so on. It goes like this-

3 Stores:
Store A
New Jersey
Apples,9,$3.82
Milk,4,$1.50
Eggs,100,$0.97
Chocolates,16,$0.40

Store B
New York
Entry Phone,5,$200.00
Mid range Phone,3,$650.00
Flagship Phone,8,$1000.00

Store C
New Jersey
Milk,50,$2.50
Eggs,200,$0.50
Soda,150,$1.90
Entry Phone,10,$185.00

How to define the specific lines of all the paragraphs to print some thing like-

There are 3 store(s) in total 
Store A is in New Jersey
Store B is in New York
Store C is in New Jersey

I can't just print it out myself by counting it, there can be any number of stores and different locations. It has to be general enough to work with different inventory data.

Similarly how to define the inventory list to be in the order of item name, quantity and price for all the stores/paragraphs?

I hope the question is clear enough. Thanks!

Aucun commentaire:

Enregistrer un commentaire