Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Background List inventory contains sublists of the form [cost,quantity]: for several products in a store cost: cost per item quantity. number of items in stock

image text in transcribed

Background List inventory contains sublists of the form [cost,quantity]: for several products in a store cost: cost per item quantity. number of items in stock For example, inventory [20.0, 3.0], [18.5, 4.0], [19.3, 2.011 For the first product in inventory, there are 3.0 items in stock and each item costs $20.0 Your Task (a) Write a function inventory_details which accepts parameter inventory and returns an array array A sample output is shown below: C20 [18.5 4. 1 [19.3 2. 11 (b) Write a function product_cost which accepts parameter array (the output from part a) as input and returns the total cost of each product as a 1-dimensional array. The total cost of each product is cal culated using the formula cost*product. A sample output is shown below: 60 74. 38.6] (c) Suppose the store is applying a discount of 30% to all products. Write a function called discount Which accepts parameter array (the output from part a) as input and returns a 2-dimensional array array which contains the discounted cost and the number of items in stock for each product. A sample output is shown below: L [14 [12.95 4. [13.51 2. ]] (d) Write a function total_cost which accepts parameter array (the output from part c) as input and returns a value which is the total cost of ALL products in the store using the discounted cost from part c. The total cost of all products in the store is computed as follows using the sample output shown in part (c) (14.0 3.0) (12.95 4.0) + (13.51 2.0)120.82 A sample output is shown below 120.82

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Administration The Complete Guide To Dba Practices And Procedures

Authors: Craig S. Mullins

2nd Edition

0321822943, 978-0321822949

More Books

Students also viewed these Databases questions

Question

What rules, if any, should govern mobile marketing to children?

Answered: 1 week ago