Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

X delivers milk to every house in a particular area which has about 25 houses. Every day each house requires a different quantity of milk.

X delivers milk to every house in a particular area which has about 25 houses. Every day each house requires a different quantity of milk. He has only 20mL, 50mL, and 70mL jars to measure. Since a jar does not have any reading other than the maximum value such as 20mL, X cannot measure if the amount of milk is less than the maximum of the jar. The customer asks for the required amount of milk only in milliliters. For instance, no jar can be used for 15mL milk or 45 ml milk. He has to use the jars a minimum number of times and measure the volume of milk required so that he doesnt make the customer wait for a long time. If he is not able to measure exactly the requested quantity, he tells Sorry, Cannot measure the required volume. Help him find the minimum number of times the jars can be used. Get the required quantity of milk from the user and calculate the minimum number of times the jars has to be used to exactly measure the quantity required and print the result in the expected format as below. If the exact quantity cannot be measured, print Sorry !!! Cannot measure the required volume

Input

The first line contains an integer input with the total volume of milk required.

Examples:

Input: 170

Output: The minimum number of jars used is 3

Input: 0

Output: The minimum number of jars used is 0

Input: 271

Output: Sorry !!! Cannot measure the required volume

How:

You should write a recursive function to get the desired output. You should use only 20,50,70 as the available jars volume.

Calculate_minimun_jars(milk_amount) //milk_amount: integer amount of milk volume to be measured

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

Practical Database Programming With Visual Basic.NET

Authors: Ying Bai

1st Edition

0521712351, 978-0521712354

More Books

Students also viewed these Databases questions

Question

Briefly describe the negative pledge and cross-default clauses?

Answered: 1 week ago