Advertisement
Guest User

Exam Problem

a guest
Jul 1st, 2016
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5. static void Main()
  6. {
  7. int n = int.Parse(Console.ReadLine());
  8. decimal total = 0;
  9. for (int i = 0; i < n; i++)
  10. {
  11. decimal pricePerCapsule = decimal.Parse(Console.ReadLine());
  12. DateTime date = DateTime.ParseExact(Console.ReadLine(), "d/M/yyyy",
  13. System.Globalization.CultureInfo.InvariantCulture);
  14. decimal capsulesCount = decimal.Parse(Console.ReadLine());
  15. decimal daysInMonth = DateTime.DaysInMonth(date.Year, date.Month);
  16.  
  17. decimal totalPrice = (daysInMonth * capsulesCount) * pricePerCapsule;
  18. Console.WriteLine("The price for the coffee is: ${0:F2}", totalPrice);
  19. total += totalPrice;
  20. }
  21. Console.WriteLine("Total: ${0:F2}", total);
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement