Advertisement
Guest User

Untitled

a guest
Feb 12th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 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 ConsoleApplication9
  8. {
  9. using System.Numerics;
  10.  
  11. class Program
  12. {
  13. static void Main(string[] args)
  14. {
  15.  
  16.  
  17.  
  18.  
  19. //Console.WriteLine("number cakes n: ");
  20. decimal cakesAmount = decimal.Parse(Console.ReadLine());
  21. //Console.WriteLine("necflour c: ");
  22. decimal kilograms = decimal.Parse(Console.ReadLine());
  23. //Console.WriteLine("all flour f: ");
  24. decimal availableFlour = decimal.Parse(Console.ReadLine());
  25. //Console.WriteLine("all truffles t: ");
  26. long truffels = long.Parse(Console.ReadLine());
  27. //Console.WriteLine("price of truffles p: ");
  28. decimal priceOfTruffel = decimal.Parse(Console.ReadLine());
  29.  
  30. decimal flourneed = cakesAmount * kilograms; //123*1.2=147.6
  31.  
  32. decimal price = 0;
  33. if (availableFlour >= flourneed) //150>147.6 >> true
  34. {
  35. price = (truffels/cakesAmount);
  36. price = price*priceOfTruffel;
  37. price = price*1.25m; //(15/123)*2000*(1.25) = 304.878
  38. Console.WriteLine("All products available, price of a cake: {0:F2}", price);
  39. }
  40. else
  41. {
  42. decimal posscake = Convert.ToInt32(Math.Truncate(availableFlour / kilograms));
  43. decimal neededflour = flourneed - availableFlour;
  44. Console.WriteLine("Can make only {0} cakes, need {1:F2} kg more flour", posscake, neededflour);
  45. }
  46.  
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement