interview
Programming and Technical
Programming
Arrays
Let Say, We've got 3 Kinds of Fruits such are Banana (0.5Rs), Oranges (1Rs), Apple (5Rs) and 100Rs money.
Now I would like buy 100 Fruits of all 3 kinds for 100Rs.
So, I want you to display all the possible combinations of Fruits ratios.
Find Fruits Combination (Should include all of 3 fruit types) to get 100 fruits for 100 Rs.
Read Solution (Total 2)
-
- public class PossibleFruitsCombinations {
public static String getPossibleFruitsCombinations(int apple,int orange,float banana) {
int x,l,m;
float n,count;
String result="";
for(int i=1;i - 7 years agoHelpfull: Yes(7) No(13)
- Total 11 combinations
(88,1,11), (80,10,10), (72,19,9) , (64,28,8), (56,37,7) , (48,46,6), (40,55,5), (32,64,4), (24,73,3) ,(16,82,2), (8,91,1)
If number of banana, oranges and apples are x,y & z respectively, then
x+y+z=100 ---(i) and
0.5x + y + 5z=100 or x+2y+10z=200 ---(ii)
Subtracting (i) from (ii), y+9z=100 ---(iii) , so calculating values of y & z for (iii), which will give values of 'x'
- 9 years agoHelpfull: Yes(2) No(1)
interview Other Question