braveheart1989

s

Jun 12th, 2016
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.19 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 ConsoleApplication2
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             //((daysInMonth * capsulesCount) * pricePerCapsule)
  15.             int countOfOrder = int.Parse(Console.ReadLine());
  16.  
  17.  
  18.             decimal total = 0;
  19.  
  20.             for (int order = 0; order < countOfOrder; order++)
  21.             {
  22.                 decimal pricePerCapsule = decimal.Parse(Console.ReadLine());
  23.                 var orderDate = Console.ReadLine();
  24.                 var date = DateTime.ParseExact(orderDate, "d/M/yyyy", CultureInfo.InvariantCulture);
  25.  
  26.                 int days = DateTime.DaysInMonth(date.Year, date.Month);
  27.                 long capsulesCount = long.Parse(Console.ReadLine());
  28.                 var orderPrice = days*capsulesCount*pricePerCapsule;
  29.  
  30.                 Console.WriteLine("The price for the coffee is: ${0:F2}", orderPrice);
  31.                 total += orderPrice;
  32.             }
  33.             Console.WriteLine("Total: ${0:F2}",total);
  34.             //Console.WriteLine(orderPrice);
  35.  
  36.         }
  37.     }
  38. }
Add Comment
Please, Sign In to add comment