borkins

01. Cake Tycoon

May 1st, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.21 KB | None | 0 0
  1. /**
  2.  * Project: Exam_17_January_2016 - created by borkins on 2017-05-01.
  3.  */
  4.  
  5. import java.util.Scanner;
  6.  
  7. public class _01_CakeTycoon
  8. {
  9.     public static void main(String[] args)
  10.     {
  11.         Scanner input = new Scanner(System.in);
  12.        
  13.         int cakesWanted = Integer.parseInt(scan.nextLine());
  14.         double kgFlourForCake = Double.parseDouble(scan.nextLine());
  15.         int kgFlourAvailable = Integer.parseInt(scan.nextLine());
  16.         int trufflesAvailable = Integer.parseInt(scan.nextLine());
  17.         int trufflesPrice = Integer.parseInt(scan.nextLine());
  18.        
  19.         int cakesCanProduce = (int) (kgFlourAvailable / kgFlourForCake);
  20.        
  21.         if (cakesCanProduce < cakesWanted)
  22.         {
  23.             double kgFlourDeficit = ((double) kgFlourForCake * cakesWanted) - kgFlourAvailable;
  24.             System.out.printf("Can make only %d cakes, need %.2f kg more flour", cakesCanProduce, kgFlourDeficit);
  25.         }
  26.         else {
  27.             long trufflesCost = (long) trufflesAvailable * trufflesPrice;
  28.             double cakePrice = (double) trufflesCost / cakesWanted * 1.25;
  29.             System.out.printf("All products available, price of a cake: %.2f", cakePrice);
  30.         }
  31.     }
  32. }
Add Comment
Please, Sign In to add comment