SHARE
TWEET

Exam Problem

a guest Jul 1st, 2016 242 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top