Advertisement
Guest User

Coffee Orders

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