In a shop various products are available, create a structure to hold the product details such as prod_name, prod_id, pro

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

In a shop various products are available, create a structure to hold the product details such as prod_name, prod_id, pro

Post by answerhappygod »

In a shop various products are available, create a structure to
hold the product details such as prod_name, prod_id, prod_price,
prod_expdate, prod_rackno. Write a function to input certain number
of product details as per user’s choice. Then have an another
function which should search for a particular product either by
prod_id or by prod_name and print the complete product details, if
available. Otherwise, print “Product unavailable”.
Note:-
Negative and zero input values are not allowed for any
attributes. Type of the attributes and methods can be decided as
per your requirements. Array of structures and arrays within
structure concept should be used.
Example:-
Test cases:-
case=one
input= 3 (no of products)
Juice (product name)
125 (product id)
155 (product prize)
10-12-2023 (product expiry date)
5 (product rackno)
Onion (product name)
127 (product id)
55 (product prize)
10-06-2022 (product expiry date)
15 (product rack no)
Cake (product name)
123 (product id)
16 (product prize)
05-06-2022 (product expiry date)
8 (product rack no)
1 (choice for searching as per prod_id)
123 (product id to be searched)
output=Cake (product name)
123 (product id)
16 (product prize)
05-06-2022 (product expiry date)
8 (product rack no)
grade reduction=15%
case=two
input= 3 (no of products)
Juice (product name)
125 (product id)
155 (product prize)
10-12-2023 (product expiry date)
5 (product rackno)
Onion (product name)
127 (product id)
55 (product prize)
10-06-2022 (product expiry date)
15 (product rack no)
Cake (product name)
123 (product id)
16 (product prize)
05-06-2022 (product expiry date)
8 (product rack no)
2 (choice for searching as per prod_name)
Onion (product name to be searched)
output=Onion (product name)
127 (product id)
55 (product prize)
10-06-2022 (product expiry date)
15 (product rack no)
grade reduction=15%
case=three
input= 3 (no of products)
Lamp oil (product name)
125 (product id)
155 (product prize)
10-12-2023 (product expiry date)
5 (product rackno)
Onion (product name)
127 (product id)
55 (product prize)
10-06-2022 (product expiry date)
15 (product rack no)
Cake (product name)
123 (product id)
16 (product prize)
05-06-2022 (product expiry date)
8 (product rack no)
0 (Wrong choice)
output=Invalid
grade reduction=15%
case=four
input= -3 (no of products)
output=Invalid
grade reduction=15%
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply