LardaX

Softuni-Coffee-Orders

Oct 19th, 2016
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.00 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 Softuni_Coffee_Orders
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             int count = int.Parse(Console.ReadLine());
  15.             decimal totalPrice = 0;
  16.  
  17.             for (int i = 0; i < count; i++)
  18.             {
  19.                 decimal price = decimal.Parse(Console.ReadLine());
  20.                 DateTime orderDate = DateTime.ParseExact(Console.ReadLine(), "d/M/yyyy", CultureInfo.InvariantCulture);
  21.                 long capsulesCount = long.Parse(Console.ReadLine());
  22.  
  23.                 decimal coffeePrice = (DateTime.DaysInMonth(orderDate.Year, orderDate.Month) * capsulesCount) * price;
  24.                 totalPrice += coffeePrice;
  25.                 Console.WriteLine($"The price for the coffee is: ${coffeePrice:f2}");
  26.             }
  27.             Console.WriteLine($"Total: ${totalPrice:f2}");
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment