Advertisement
Guest User

Untitled

a guest
Feb 1st, 2015
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. using System;
  2.  
  3. namespace garden
  4. {
  5. class garden
  6. {
  7. static void Main()
  8. {
  9.  
  10. decimal tomatoSeeds = decimal.Parse(Console.ReadLine());
  11. int tomatoArea = int.Parse(Console.ReadLine());
  12. decimal cucumberSeeds = decimal.Parse(Console.ReadLine());
  13. int cucumberArea = int.Parse(Console.ReadLine());
  14. decimal potatoSeeds = decimal.Parse(Console.ReadLine());
  15. int potatoArea = int.Parse(Console.ReadLine());
  16. decimal carrotSeeds = decimal.Parse(Console.ReadLine());
  17. int carrotArea = int.Parse(Console.ReadLine());
  18. decimal cabbageSeeds = decimal.Parse(Console.ReadLine());
  19. int cabbageArea = int.Parse(Console.ReadLine());
  20. decimal beanSeeds = decimal.Parse(Console.ReadLine());
  21.  
  22. decimal tomatoPrice = 0.5M;
  23. decimal cucumberPrice = 0.4M;
  24. decimal potatoPrice = 0.25M;
  25. decimal carrotPrice = 0.6M;
  26. decimal cabbagePrice = 0.3M;
  27. decimal beansPrice = 0.4M;
  28.  
  29. decimal tomatoCost = tomatoSeeds * tomatoPrice;
  30. decimal cucumberCost = cucumberSeeds * cucumberPrice;
  31. decimal potatoCost = potatoSeeds * potatoPrice;
  32. decimal carrotCost = carrotSeeds * carrotPrice;
  33. decimal cabbageCost = cabbageSeeds * cabbagePrice;
  34. decimal beansCost = beanSeeds * beansPrice;
  35.  
  36. int totalArea = 250;
  37. decimal totalPrice = tomatoCost + cucumberCost + potatoCost + carrotCost + cabbageCost + beansCost;
  38.  
  39. double beansArea = totalArea - (tomatoArea + cucumberArea + potatoArea + carrotArea + cabbageArea);
  40.  
  41. if((tomatoArea + cucumberArea + potatoArea + carrotArea + cabbageArea) > totalArea)
  42. {
  43. Console.WriteLine("Total costs: {0}", totalPrice, Math.Round(totalPrice, 2));
  44. Console.WriteLine("Insufficient area!");
  45. }
  46.  
  47. else if (beansArea <= 0)
  48. {
  49. Console.WriteLine("Total costs: {0}", totalPrice, Math.Round(totalPrice, 2));
  50. Console.WriteLine("No area for beans!");
  51. }
  52. else
  53. {
  54. Console.WriteLine("Total costs: {0}", totalPrice, Math.Round(totalPrice, 2));
  55. Console.WriteLine("Beans area: {0}", beansArea, Math.Round(beansArea, 2));
  56. }
  57.  
  58. }
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement