import java.util.Scanner; /** * Created by entropy on 5/1/2017. */ public class cakes { public static void main(String[] args) { Scanner scanner = new Scanner (System.in); // The number n – amount of cakes Ivancho wants. //• The number c – kilograms of flour needed to make one cake. //• The number f – kilograms of flour available. //• The number t – amount of truffles available. //• The number p – price of one truffle. int cakesWanted=Integer.parseInt(scanner.nextLine()); double flourNeededPerCake=Double.parseDouble(scanner.nextLine()); int kgFloorAvailable=Integer.parseInt(scanner.nextLine()); int trufflesAvailable=Integer.parseInt(scanner.nextLine()); int trufflePrice=Integer.parseInt(scanner.nextLine()); double maxFlour=cakesWanted*flourNeededPerCake; //if flour is not enough if (maxFlour>kgFloorAvailable){ double numberOfCakes=kgFloorAvailable/flourNeededPerCake; double diffFlour=flourNeededPerCake*cakesWanted-kgFloorAvailable; System.out.print("Can make only "+(int)numberOfCakes+" cakes, need "); System.out.printf("%.2f",diffFlour); System.out.println(" kg more flour"); //if floor is enough } else{ double productionCost=trufflesAvailable*trufflePrice; double cakePrice=(productionCost/cakesWanted)*1.25; System.out.print("All products available, price of a cake: "); System.out.printf("%.2f",cakePrice); } } }