Advertisement
Aborigenius

SoftUni Coffee Order

Sep 3rd, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.20 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace Task1
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             int N = int.Parse(Console.ReadLine());
  15.             var total = new List<decimal>();
  16.             for (int i = 0; i < N; i++)
  17.             {
  18.                 decimal pricePerCapsule = decimal.Parse(Console.ReadLine());
  19.                 string orderdate = Console.ReadLine();
  20.                 DateTime myDate = DateTime.ParseExact(orderdate, "d/M/yyyy", CultureInfo.InvariantCulture);
  21.                 int daysInMonth = System.DateTime.DaysInMonth(myDate.Year, myDate.Month);
  22.                 uint capsulesCount = uint.Parse(Console.ReadLine());
  23.                 decimal totalPerOrder = ((daysInMonth * capsulesCount) * pricePerCapsule);
  24.                 Console.WriteLine($"The price for the coffee is: ${totalPerOrder:f2}");
  25.  
  26.                 total.Add(totalPerOrder);
  27.  
  28.  
  29.             }
  30.  
  31.             decimal sum = total.Sum();
  32.             Console.WriteLine($"Total: ${sum:f2}");
  33.  
  34.  
  35.  
  36.         }
  37.     }
  38. }
  39. //((daysInMonth * capsulesCount) * pricePerCapsule)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement