@@ -0,0 +1,2056 @@
+package algorithms.implementation;%0D%0A%0D%0Aimport java.util.Scanner;%0D%0A%0D%0A/*%0D%0A * Problem Statement: %0D%0A * Little Bob loves chocolate, and he goes to a store with $N in his pocket. The%0D%0A * price of each chocolate is $C. The store offers a discount: for every M%0D%0A * wrappers he gives to the store, he gets one chocolate for free. How many%0D%0A * chocolates does Bob get to eat?%0D%0A * %0D%0A * Input Format:%0D%0A * The first line contains the number of test cases, T.%0D%0A * T lines follow, each of which contains three integers, N, C, and M.%0D%0A * %0D%0A * Output Format:%0D%0A * Print the total number of chocolates Bob eats.%0D%0A * %0D%0A * Constraints:%0D%0A * 1 %3C= T %3C= 1000%0D%0A * 2 %3C= N %3C= 105%0D%0A * 1 %3C= C %3C= N%0D%0A * 2 %3C= M %3C= N%0D%0A * %0D%0A * Sample input: %0D%0A * 3%0D%0A * 10 2 5%0D%0A * 12 4 4%0D%0A * 6 2 2%0D%0A * %0D%0A * Sample Output: %0D%0A * 6%0D%0A * 3%0D%0A * 5%0D%0A */%0D%0Apublic class ChocolateFeast %7B%0D%0A%0D%0A%09public static void main(String%5B%5D args) %7B%0D%0A%09%09Scanner sc = new Scanner(System.in);%0D%0A%0D%0A%09%09int numCases = sc.nextInt();%0D%0A%0D%0A%09%09for (int i = 0; i %3C numCases; i++) %7B%0D%0A%09%09%09int totalFunds = sc.nextInt();%0D%0A%09%09%09int pricePerChocolate = sc.nextInt();%0D%0A%09%09%09int wrappersForFreeChocolate = sc.nextInt();%0D%0A%0D%0A%09%09%09int numChocolatesPurchased = totalFunds / pricePerChocolate;%0D%0A%0D%0A%09%09%09int numExtraChocolates = numFreeChocolatesFromWrappers(%0D%0A%09%09%09%09numChocolatesPurchased, wrappersForFreeChocolate, 0);%0D%0A%0D%0A%09%09%09System.out.println(numChocolatesPurchased + numExtraChocolates);%0D%0A%09%09%7D%0D%0A%09%09sc.close();%0D%0A%09%7D%0D%0A%0D%0A%09private static int numFreeChocolatesFromWrappers(int chocolatesPurchased,%0D%0A%09%09%09%09%09int wrappersForFreeChocolate, int totalFreeChocolates) %7B%0D%0A%0D%0A%09%09int additionalFreeChocolates = (chocolatesPurchased / wrappersForFreeChocolate);%0D%0A%0D%0A%09%09int leftOverWrappers = (chocolatesPurchased %25 wrappersForFreeChocolate);%0D%0A%0D%0A%09%09totalFreeChocolates += additionalFreeChocolates;%0D%0A%0D%0A%09%09if ((additionalFreeChocolates%0D%0A%09%09%09%09%09%09+ leftOverWrappers) %3C wrappersForFreeChocolate) %7B%0D%0A%09%09%09%0D%0A%09%09%09return totalFreeChocolates;%0D%0A%09%09%7D else %7B%0D%0A%09%09%09return numFreeChocolatesFromWrappers(%0D%0A%09%09%09%09%09%09%09additionalFreeChocolates + leftOverWrappers,%0D%0A%09%09%09%09%09%09%09wrappersForFreeChocolate, totalFreeChocolates);%0D%0A%09%09%7D%0D%0A%09%7D%0D%0A%7D

Add ChocolateFeast