Advertisement
Guest User

Untitled

a guest
Feb 1st, 2015
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.17 KB | None | 0 0
  1. using System;
  2. using System.Globalization;
  3. using System.Threading;
  4.  
  5. class Garden
  6. {
  7.     static void Main()
  8.     {
  9.         Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
  10.  
  11.         int tomatoSeedsAmount = int.Parse(Console.ReadLine());
  12.         int tomatoArea = int.Parse(Console.ReadLine());
  13.  
  14.         int cucumberSeedsAmount = int.Parse(Console.ReadLine());
  15.         int cucumberArea = int.Parse(Console.ReadLine());
  16.  
  17.         int potatoSeedsAmount = int.Parse(Console.ReadLine());
  18.         int potatoArea = int.Parse(Console.ReadLine());
  19.  
  20.         int carrotSeedsAmount = int.Parse(Console.ReadLine());
  21.         int carrotArea = int.Parse(Console.ReadLine());
  22.  
  23.         int cabbageSeedsAmount = int.Parse(Console.ReadLine());
  24.         int cabbageArea = int.Parse(Console.ReadLine());
  25.  
  26.         int beansSeedsAmount = int.Parse(Console.ReadLine());
  27.  
  28.  
  29.         //cost per seed
  30.  
  31.         double tomatoPerSeed = 0.5;
  32.         double cucumberPerSeed = 0.4;
  33.         double potatoPerSeed = 0.25;
  34.         double carrotPerSeed = 0.6;
  35.         double cabbagePerSeed = 0.3;
  36.         double beansPerSeed = 0.4;
  37.         //total cost
  38.         double totalCosts = 0;
  39.         totalCosts = (tomatoSeedsAmount * tomatoPerSeed) + (cucumberSeedsAmount * cucumberPerSeed) +
  40.                      (potatoSeedsAmount * potatoPerSeed) + (carrotSeedsAmount * carrotPerSeed) +
  41.                      (cabbageSeedsAmount * cabbagePerSeed) + (beansSeedsAmount * beansPerSeed);
  42.  
  43.  
  44.  
  45.  
  46.         //calculate are
  47.         int area = 250;
  48.         int sumOfAreas = tomatoArea + cucumberArea + potatoArea + carrotArea + cabbageArea;
  49.         int beansArea = area - sumOfAreas;
  50.  
  51.  
  52.         if (beansArea < 0)
  53.         {
  54.             Console.WriteLine("Total costs: {0:F2}", totalCosts);
  55.             Console.WriteLine("Insufficient area");
  56.         }
  57.         else if (beansArea == 0)
  58.         {
  59.             Console.WriteLine("Total costs: {0:F2}", totalCosts);
  60.             Console.WriteLine("No area for beans");
  61.         }
  62.         else
  63.         {
  64.             Console.WriteLine("Total costs: {0:F2}", totalCosts);
  65.             Console.WriteLine("Beans area: {0}", beansArea);
  66.         }
  67.  
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement