You are given a container of X liters containing a mixture of wine and water. The mixture contains W% of water in it. How much liters of water must be added to increase the ratio of water to Y%?
Input contains 3 integers X, W and Y respectively.
The output should be in float format up to 2 decimal points.
Input : X = 125, W = 20, Y = 25
Output : 8.33 liters
20% of 125 is 25. If we add 8.33 liters, we get 33.33 which is 25% of 133.33.
Input : X = 100, W = 50, Y = 60
Output : 25
Let the amount of water to be added be A liters.
So, the new amount of mixture = (X + A) liters
And the amount of water in the mixture = (old amount + A) = ((W % of X ) + A )
Also, the amount of water in the mixture = new percentage of water in new mixture = Y % of (X + A)
Now, we can write the expression as
Y % of ( X + A) = W % of X + A
Since, both denote the amount of water.
On simplifying this expression, we will get
A = [X * (Y – W)] / [100 – Y]
X = 125, W = 20% and Y = 25%;
So, for the given question, the amount of water to be added = (125 * (25 – 20)) / (100 – 25) = 8.33 liters
Below is the implementation of above approach:
Water to be added = 25.00
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Find the number which when added to the given ratio a : b, the ratio changes to c : d
- Program to find the quantity after mixture replacement
- Program to find amount of water in a given glass
- Find amount of water wasted after filling the tank
- Find out the minimum number of coins required to pay total amount
- Find the ratio of LCM to GCD of a given Array
- Find probability that a player wins when probabilities of hitting the target are given
- Find minimum moves to reach target on an infinite line
- Find if it is possible to get a ratio from given ranges of costs and quantities
- Program to find the common ratio of three numbers
- Find nth Fibonacci number using Golden ratio
- Find pair with maximum ratio in an Array
- Find the integers that doesnot ends with T1 or T2 when squared and added X
- Find the minimum number to be added to N to make it a power of K
- Program to find the count of coins of each type from the given ratio
- Ratio of mth and nth terms of an A. P. with given ratio of sums
- Find the ratio of number of elements in two Arrays from their individual and combined average
- Sum of two numbers if the original ratio and new ratio obtained by adding a given number to each number is given
- Find ΔX which is added to numerator and denominator both of fraction (a/b) to convert it to another fraction (c/d)
- Find the minimum number to be added to N to make it a prime number
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.