Question: ?n java programming could you help me 2) Given following three values, the task is to find the total number of maximum chocolates you can
2) Given following three values, the task is to find the total number of maximum chocolates you can eat. Imoney : Money you have to buy chocolates 2 price: Price of a chocolate 3 wrap: Number of wrappers to be returned for getting one extra chocolate It may be assumed that all given values are positive integers and greater than 1 Examples: Input money 16, price 2, wrap 2 Output: 15 Price of a chocolate is 2. You can buy 8 chocolates fro amount 16. You can return 8 wrappers back and get 4 more chocolates. Then you can return 4 wrappers and get 2 more chocolates. Finally you can return 2 wrappers to get 1 more chocolate. Input money-15, price 1, wrap-3 Output 22 We buy and eat 15 chocolates We return 15 wrappers and get 5 more chocolates We return 3 wrappers, get 1 chocolate and eat it (keep 2 wrappers). Now we have 3 wrappers. Return 3 and get 1 more chocolate. So total chocolates 15+5+1+1 Input money 20, price - 3, wrap5 Output: 7
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
