SampleExperimentNo4 2022
SampleExperimentNo4 2022
Practical No 4 Date: / /
Title: Write a C++ program using class to process shopping list for a departmental store. The list
includes details such as item code no, item name and price of each item and perform the operations
like adding, deleting items to the list and printing the total value of an order.
Description:
A class in C++ is the building block, that leads to Object-Oriented programming. It is a user-
defined data type, which holds its own data members and member functions, which can be
accessed and used by creating an instance of that class.
Classes are like templates that define common properties or attributes. Objects are instances of a
class. Once a class has been defined, we can create any number of objects belonging to that class.
Each object is associated with the data or type class with which they are created.
Declaration of class:
class <class_name>
{
data members;
member functions;
};
Hint:
Menu:
Add an item and Quantity
Display total value
Delete an item
Display all items
Exit
class item
{
int itemcode[50];
float itemprice[50];
int count;
public:
void cntzero(); //initialize count to zero
void getitem(); (hint: cin>>itemcode[count]; count++;) //assigns value to data members of class item
void displaysum(); //display total value of all items
void remove(); //ask the user to enter item code and delete the specified item
void displayitems(); // displaying items
};
PP Lab Name: PRN:
Program Code:
Practice programs: Write a program that would print the information (name, year of joining,
salary, address) of three employees by creating a class named 'Employee'. The output should be as
follows:
Name Year of joining Address
Rahul 2010 64C- WallsStreat
Samar 2000 68D- WallsStreat
Ishita 2018 26B- WallsStreat