Advertisement
baxlash

Cake Tycoon

Mar 10th, 2016
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 KB | None | 0 0
  1. using System;
  2.  
  3. class CakeTycoon
  4. {
  5.     public static void Main (string[] args)
  6.     {
  7.         ulong numberOfCakes = ulong.Parse (Console.ReadLine ());
  8.         double flourNeededPerCake = double.Parse (Console.ReadLine ());
  9.         ulong flourAvailable = ulong.Parse (Console.ReadLine ());
  10.         ulong truffles = ulong.Parse (Console.ReadLine ());
  11.         ulong trufflesPrice = ulong.Parse (Console.ReadLine ());
  12.  
  13.         double cakesMakable = flourAvailable / flourNeededPerCake;
  14.  
  15.         if (cakesMakable > numberOfCakes) {
  16.             ulong trufflesCost = truffles * trufflesPrice;
  17.             double cakePrice = (trufflesCost / numberOfCakes) * 1.25;
  18.  
  19.             Console.WriteLine (
  20.                 "All products available, price of a cake: {0:F2}",
  21.                 cakePrice);
  22.         } else {
  23.             double totalFlourNeeded = numberOfCakes * flourNeededPerCake;
  24.             double differenceInFlour = totalFlourNeeded - flourAvailable;
  25.  
  26.             Console.WriteLine (
  27.                 "Can make only {0} cakes, need {1:F2} kg more flour",
  28.                 Math.Floor (cakesMakable),
  29.                 differenceInFlour);
  30.         }
  31.  
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement