Advertisement
nivanov93

SoftuniCoffeeOrders

Jun 12th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.14 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. using System.Numerics;
  7.  
  8. class SoftuniCoffeeOrders
  9. {
  10.     static void Main()
  11.     {
  12.         int numberOfOrders = int.Parse(Console.ReadLine());
  13.         decimal overallProfit = 0;
  14.  
  15.         for (int currentOrder = 0; currentOrder < numberOfOrders; currentOrder++)
  16.         {
  17.             BigInteger pricePerCaps = BigInteger.Parse(Console.ReadLine());
  18.             DateTime daysInMon = DateTime.ParseExact(Console.ReadLine(),
  19.                 "d/M/yyyy", System.Globalization.CultureInfo.InvariantCulture);
  20.             int days = DateTime.DaysInMonth(daysInMon.Year, daysInMon.Month);
  21.  
  22.             int capsulesCount = int.Parse(Console.ReadLine());
  23.             decimal profit = ((days * (decimal)capsulesCount) * (decimal)(pricePerCaps));
  24.  
  25.             overallProfit += profit;
  26.  
  27.             if (profit > overallProfit)
  28.             {
  29.                 profit++;
  30.             }
  31.             Console.WriteLine($"The price for the coffee is: ${profit:f2}");
  32.             Console.WriteLine($"Total: ${overallProfit:f2}");
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement