0% found this document useful (0 votes)
3 views2 pages

DSA_Filehandling

The document outlines the structure and requirements for managing a computer store's inventory using a CSV file. It specifies how to read product data, handle missing values, and generate an inventory report with calculated inventory values. Functions are defined for reading individual products, reading a product list, and writing an inventory report.

Uploaded by

Gaming NHQ
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

DSA_Filehandling

The document outlines the structure and requirements for managing a computer store's inventory using a CSV file. It specifies how to read product data, handle missing values, and generate an inventory report with calculated inventory values. Functions are defined for reading individual products, reading a product list, and writing an inventory report.

Uploaded by

Gaming NHQ
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

File Handling: Computer Store Inventory Management

Data Description
The file "inventory.csv" contains product information for a computer store. The initial lines of the file
appear as:
ProductID , Category , CPU , GPU , RAM , Storage , Price , Stock
COM001 , Laptop , i7 -10750 H , RTX3060 ,16 GB ,512 GB SSD ,1200 ,10
COM002 , Desktop , Ryzen 5 3600 , GTX1660 Super ,32 GB ,1 TB HDD ,800 ,5
COM003 , Laptop , , , ,600 , ,8
COM004 , Monitor , , , ,250 ,15
COM005 , Desktop , i5 -10400 , UHD 630 ,16 GB ,512 GB NVMe ,700 ,3
Where:

• The first line lists field names


• Subsequent lines represent individual products
• Empty fields indicate missing data:

– Missing numeric fields (Price/Stock) are treated as 0


– Missing component fields (CPU/GPU/RAM/Storage) are treated as ”N/A”
• Inventory value should be calculated as Price × Stock

Programming Requirements
Given the Product structure definition:
// Product . h
struct Product {
string productID ;
string category ;
string cpu ;
string gpu ;
string ram ;
string storage ;
float price ;
int stock ;
float inventoryValue ;
string components ;
};

Implement these functions:

1. Read Individual Product

Product readProduct ( string lineInfo );

• Input: A line from inventory.csv


• Output: Product struct with:
– Components string formatted as ”CPU:...; GPU:...; RAM:...; Storage:...”
– InventoryValue = Price × Stock (handle missing values as 0)

1
2. Read Product List

vector < Product > readProductList ( string fileName );

• Input: Path to inventory.csv


• Output: Vector of all products in file

3. Generate Inventory Report

void writeReport ( vector < Product > products , string outFile );

• Input: Product list and output filename


• Output: File containing:

– First line: ”ID Category InventoryValue Components”


– Subsequent lines: Product details in format
COM001 Laptop 12000 CPU:i7-10750H;GPU:RTX3060;RAM:16GB;Storage:512GB SSD
– Missing components shown as ”N/A”

Sample Output
ID Category InventoryValue Components
COM001 Laptop 12000 CPU : i7 -10750 H ; GPU : RTX3060 ; RAM :16 GB ; Storage :512 GB SSD
COM003 Laptop 0 CPU : N / A ; GPU : N / A ; RAM : N / A ; Storage : N / A
COM005 Desktop 2100 CPU : i5 -10400; GPU : UHD 630; RAM :16 GB ; Storage :512 GB NVMe

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy