Advertisement
sivancheva

Cake

May 26th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _01_CakeTycoon
  8. {
  9. class cakeTycoon
  10. {
  11. static void Main(string[] args)
  12. {
  13. // The number n – amount of cakes Ivancho wants.
  14. //• The number c – kilograms of flour needed to make one cake.
  15. //• The number f – kilograms of flour available.
  16. //• The number t – amount of truffles available.
  17. //• The number p – price of one truffle.
  18.  
  19. ulong n = ulong.Parse(Console.ReadLine());
  20. decimal c = decimal.Parse(Console.ReadLine());
  21. uint f = uint.Parse(Console.ReadLine());
  22. uint t = uint.Parse(Console.ReadLine());
  23. uint p = uint.Parse(Console.ReadLine());
  24.  
  25. var cakesCanBeMade = Math.Truncate( f / c);
  26. var flouirForWishNumberOfCakes = n * c;
  27. var diffFlour = flouirForWishNumberOfCakes - f;
  28. decimal priceCake = (t * p )/ n;
  29. decimal priceTotal = priceCake*(decimal)1.25;
  30.  
  31. if (cakesCanBeMade<n)
  32.  
  33. {
  34. Console.WriteLine("Can make only {0} cakes, need {1:f2} kg more flour", cakesCanBeMade, diffFlour);
  35.  
  36. }
  37. else
  38. {
  39. Console.WriteLine("All products available, price of a cake: {0}",priceTotal);
  40. }
  41.  
  42. }
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement