0% found this document useful (0 votes)
16 views5 pages

Spring 2025 - CS301 - 1

The assignment requires students to create a C++ program that implements a queue using a linked list to manage inventory for XYZ Electronics. Students must add products based on the last three digits of their student ID and follow FIFO principles. The program must include a Product class and a Queue class with specified functions, and submissions must adhere to strict formatting and submission guidelines.

Uploaded by

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

Spring 2025 - CS301 - 1

The assignment requires students to create a C++ program that implements a queue using a linked list to manage inventory for XYZ Electronics. Students must add products based on the last three digits of their student ID and follow FIFO principles. The program must include a Product class and a Queue class with specified functions, and submissions must adhere to strict formatting and submission guidelines.

Uploaded by

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

Assignment No.

01
Total Marks: 20
SEMESTER Spring 2025
Due Date: May 05,2025
CS301- Data Structures

Instructions
Please read the following instructions carefully before solving & submitting assignment:
It should be clear that your assignment will not get any credit (zero marks) if:
o The assignment is submitted after the due date.
o The submitted code does NOT compile.
o The submitted assignment is other than .CPP file.
o The submitted assignment does NOT open or file is corrupted.
o The assignment is copied (from other student or ditto copy from handouts or internet).
o If Queue is not implemented through linked list.
Uploading instructions
For clarity and simplicity, you are required to Upload/Submit only ONE .cpp file.
The submitted assignment must be in .cpp format.

Note: Use ONLY Dev-C++ IDE.

Learning Objectives:

 Practice OOP in C++


 Implement a Queue using Linked List
 Understand and use pointers effectively
 Apply real-world inventory logic using programming constructs

For any query about the assignment, contact at [email protected]

GOOD LUCK
Marks: 20

Problem Statement

XYZ Electronics is a retail store that deals in a variety of electronic gadgets such as smartphones, tablets, watches,
and accessories. As new stock arrives, it is added to the store’s backroom inventory in a First-In-First-Out (FIFO)
manner for easy tracking and retrieval during sales.

To manage the stock effectively, XYZ Electronics wants you to create a C++ program that mimics a queue-based
system using a linked list. This program will automatically add smartphones, tablets, and smart watches,
where the count of each product is determined by the last three digits of your Student ID.

For example, if your Student ID ends in 789, the system will:


 Add 7 smartphones

 Add 8 tablets
 Add 9 smart watches
Your program must not require any user input and must follow a FIFO approach to manage inventory.

Your Task:
You are required to develop a program that:
 Records each electronic product as it arrives.

 Maintains inventory in a Queue format using a linked list.


 Allows the staff to view the first and last product and remove it once sold.

You must create the following classes:

1. Product Class

Attributes (all private):


 int data → Represents the product’s internal serial data.

 Product* next → Points to the next product in the queue.


 int productId → Unique identifier for the product.
Functions:
 int getData() → Returns the value of data.

 void setData(int data) → Sets the value of data.


 Product* getNext() → Returns the pointer to the next product node.
 void setNext(Product* nextNode) → Sets the next pointer.
 int getProductId() → Returns the productId.
 void setProductId(int pid) → Sets the productId.
2. Queue Class
Attribute (private):
 Product* front → Pointer to the front of the queue.

 Product* rear → Pointer to the rear of the queue.


Functions:
 void enqueue(int data, int pid) → Adds a product with serial data and product ID pid to the inventory (at the
rear of the queue).
 int dequeue() → Removes the front product from the inventory when it is sold.
 void displayFront() → display the first element of the queue
 void displayRear() → display last element of the queue

Main Function:
 In main function declare a variable of string data type and assign it to your vu student id.
 Find last three digits from your complete vu student id.
 Declare a variable and assign serial number 1 to it and then generate unique product ids.
 Declare Queue class object then add your respective data by calling its enqueue (int data, int pid) function
by providing serial number and product id.
 Call the displayFront() and displayRear() functions to display the first and last element of the queue.
 Call the dequeue() function two times and then display the front element.

Note: Your output should be according to the given sample output according to your own VUID.

Suppose your VU Student ID is: BC123456789

The last four digits are: 6789, so, the first product ID will be= 6789

After that, each new product will have its product ID incremented by 1, such as:

First product id= 6789

Second product id= 6790

Third product id= 6791

And so on…

Now, from the last three digits of your Student id (for example 789):
7 number of smartphone should be added in the Queue with serial number 1 to 7 with unique product ids

8 number of tablets should be added in the Queue with serial number 8 to 15 with unique product ids

9 number of smart watches should be added in the Queue with serial number 16 to 24 with unique product ids

Sample Output:

Lectures Covered: This assignment covers Lecture # 1-9.


Deadline: Your assignment must be uploaded/submitted on or before, 5th May 2025.

You might also like