Advertisement
ralka

02. SoftUni Coffee Orders

Jun 13th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 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. class SoftuniCoffeeOrders
  9. {
  10.     static void Main(string[] args)
  11.     {
  12.         int n = int.Parse(Console.ReadLine());
  13.  
  14.         decimal totalPrice = 0;
  15.  
  16.         for (int i = 0; i < n; i++)
  17.         {
  18.             decimal orderPrice = 0;
  19.  
  20.             decimal pricePerCapsule = decimal.Parse(Console.ReadLine());
  21.             string inputDate = Console.ReadLine();
  22.             DateTime orderDate = DateTime.ParseExact(inputDate, "d/M/yyyy", CultureInfo.InstalledUICulture);
  23.             uint capsuleCount = uint.Parse(Console.ReadLine());
  24.  
  25.             int daysInMonth = DateTime.DaysInMonth(orderDate.Year, orderDate.Month);
  26.             orderPrice = (daysInMonth * capsuleCount) * pricePerCapsule;
  27.  
  28.             Console.WriteLine($"The price for the coffee is: ${orderPrice:f2}");
  29.  
  30.             totalPrice += orderPrice;
  31.         }
  32.  
  33.         Console.WriteLine($"Total: ${totalPrice:f2}");
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement