Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

using MatLab please using MatLab please (b) Shop A is selling a beverage which costs $2 per bottle and there are rules for promotional sales

image text in transcribed
using MatLab please
using MatLab please
(b) Shop A is selling a beverage which costs $2 per bottle and there are rules for promotional sales for the beverage: You can exchange 4 caps for 1 full bottle of the same beverage for free; . You can exchange 2 empty bottles (without cups) for 1 full bottle of the same beverage for free You have $10 in your pocket. What is the maximum number of bottles of the beverage you can get? Solve this question by writing a function maxBeverageBottles. The function can be called as below: maxBeverageBottles(money, pricePerNewBottle, capsPerNewBottle, emptyBottlesPerNewBottle) which returns the maximum number of bottles you can get with money. money is the amount of money available; priceperNewBottle is the unit price for buying a new bottle; capsPer NewBottle is the number of caps needed for exchanging 1 free bottle; . emptyBottlesPerNewBottle is the number of empty bottles needed for exchanging 1 free bottle Then in the script file, store the result of calling maxBeverageBottles(10, 2, 4, 2) to maxBottlesi. What if you have $1000 in your pocket, the beverage still costs $2/bottle, but 5 caps/bottle or 3 empty bottles/bottle for exchanging a new free bottle, how many bottles can you get? Store the result to maxBottle. You may find floor and mod useful. Hint: For each new bottle you get, you have a new pair of cap and empty bottle (after con- sumed). So you can get new bottles until no enough money/caps/empty bottles

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

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

More Books

Students explore these related Databases questions

Question

Provide examples of Dimensional Tables.

Answered: 3 weeks ago