Skillrack IL 5

Solutions for Skillrack CSE1002 Inlab 5

Total time : 20 mins

Challenges : 1

Question (Electronics Store Problem)

XYZ  electronics store has three different products in their store such as Television, Refrigerator and Washing machine. Create a C++ class to process the basic details about the electronic products in the store, such as the name of the product, product code, product price and number of products in stock. Create another C++ class to support the store keeper to maintain the stock details in the store. Write a non member function to help the store keeper to find the products whose stock is less than 10.

Input Format:
The first line will contain the number of products n.
Name of the product
Product code
Price
stock in hand

Output Format:
The complete details of the product whose available stock is less than 10

Boundary Conditions:
n=3

Solution

#include< iostream >
using namespace std;
class store_keeper;
class item
{
char prod_name[30];
char prod_code[10];
float prod_price;
int stock_In_Hand;
public:
void get();
void print()const;
friend class store_keeper;
};
class store
{
int num_Of_Items;
item items[20];
public:
void get_details();
void print_details()const;
friend class store_keeper;
};
class store_keeper
{
char name[30];
char id[10];
public:
void get();
void print();
//Function used to print name and id of products
// with stock_In_Hand less than 10
void stock_mgmt(store &);
};

void item :: get()
{
	cin>>prod_name>>prod_code>>prod_price>>stock_In_Hand;
}
void item :: print()const
{
	cout<<prod_name<<"\n"<<prod_code<<"\n"<<prod_price<<"\n"<<stock_In_Hand<<"\n";
}

void store :: get_details()
{
	cin>>num_Of_Items;
	for(int i=0;i < num_Of_Items;i++)
	items[i].get();
}
void store :: print_details()const{}

void store_keeper :: get(){}
void store_keeper :: print(){}
void store_keeper :: stock_mgmt(store &s)
{
	for(int i=0;i < s.num_Of_Items;i++)
	if(s.items[i].stock_In_Hand < 10)
	s.items[i].print();
}

main()
{
store s;
store_keeper sk;
s.get_details();
sk.stock_mgmt(s);
}

Input

INPUT :

3
RAM
1001
20000
12
SSD
1002
10000
3
Monitors
1005
12000
9

Output

OUTPUT :

SSD
1002
Monitors
1005

Advertisements

2 thoughts on “Skillrack IL 5

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s