svetlozar_kirkov

Garden (BG Coder)

Oct 15th, 2014
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.47 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.Linq;
  5. using System.Threading;
  6.  
  7. namespace ConsoleTests
  8. {
  9.     class ConsoleTests
  10.     {
  11.         static void Main()
  12.         {
  13.             Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-GB");
  14.  
  15.             int[] seeds = new int[5];
  16.             int[] areas = new int[5];
  17.             decimal[] vegetablesPrices = new decimal[]{0.5M, 0.4M, 0.25M, 0.6M, 0.3M};
  18.             for (int i = 0; i < 5; i++)
  19.             {
  20.                 seeds[i] = int.Parse(Console.ReadLine());
  21.                 areas[i] = int.Parse(Console.ReadLine());
  22.             }
  23.             int beansSeeds = int.Parse(Console.ReadLine());
  24.             decimal beansPrice = 0.4M;
  25.             decimal totalSeedsCost = 0;
  26.             for (int i = 0; i < 5; i++)
  27.             {
  28.                 totalSeedsCost += seeds[i]*vegetablesPrices[i];
  29.             }
  30.             totalSeedsCost += beansSeeds*beansPrice;
  31.             Console.WriteLine("Total costs: {0:F2}", totalSeedsCost);
  32.             double areaSum = areas.Sum();
  33.             if (areaSum > 250)
  34.             {
  35.                 Console.WriteLine("Insufficient area");
  36.             }
  37.             else if (areaSum < 250)
  38.             {
  39.                 Console.WriteLine("Beans area: {0}", 250-areaSum);
  40.             }
  41.             else
  42.             {
  43.                 Console.WriteLine("No area for beans");
  44.             }
  45.  
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment