Advertisement
YavorGrancharov

01. Softuni Coffee Orders

Nov 3rd, 2017
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.03 KB | None | 0 0
  1. using System;
  2. using System.Globalization;
  3.  
  4. namespace Softuni_Coffee_Orders
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             int n = int.Parse(Console.ReadLine());
  11.  
  12.             decimal result = 0M;
  13.             for (int i = 0; i < n; i++)
  14.             {
  15.                 decimal pricePerCapsule = decimal.Parse(Console.ReadLine());
  16.                 string orderDate = Console.ReadLine();
  17.                 string format = "d/M/yyyy";
  18.                 DateTime dateTime = DateTime.ParseExact(orderDate, format, CultureInfo.InvariantCulture);
  19.                 decimal capsulesCount = decimal.Parse(Console.ReadLine());
  20.  
  21.                 int days = DateTime.DaysInMonth(dateTime.Year, dateTime.Month);
  22.                 decimal coffeePrice = (days * capsulesCount) * pricePerCapsule;
  23.                 Console.WriteLine("The price for the coffee is: ${0:F2}", coffeePrice);
  24.                 result += coffeePrice;
  25.             }
  26.             Console.WriteLine("Total: ${0:F2}", result);
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement