Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Numerics;
- namespace CoffeeOrders
- {
- class CoffeeCost
- {
- static void Main(string[] args)
- {
- int N = int.Parse(Console.ReadLine());
- Dictionary<DateTime,int> Dictionary = new Dictionary<DateTime,int>();
- DateTime[] newdDateTime=new DateTime[N];
- int[] numberofPills = new int[N];
- int[] numberofDays = new int[N];
- decimal[] initialprices=new decimal[N];
- decimal[] prices = new decimal[N];
- decimal totalPrice = 0;
- for (int i = 0; i < N; i++)
- {
- initialprices[i] = decimal.Parse(Console.ReadLine());
- Dictionary.Add(DateTime.ParseExact(Console.ReadLine(),"d/M/yyyy",null), int.Parse(Console.ReadLine())); //Add key/value pairs to dictionary
- foreach(KeyValuePair<DateTime,int> pair in Dictionary)
- {
- numberofPills[i]=pair.Value; //assing KeyValue p
- }
- foreach (KeyValuePair<DateTime, int> secondpair in Dictionary)
- {
- numberofDays[i] = DateTime.DaysInMonth(secondpair.Key.Year,secondpair.Key.Month); //get DaysInMonth via passing keyvaluepair Key and Value as arguments
- }
- prices[i] += ((decimal)numberofDays[i] * (decimal)numberofPills[i] * initialprices[i]); //calculate prices for coffee
- totalPrice += prices[i];
- }
- for (int j = 0; j < N; j++)
- {
- Console.WriteLine("The price for the coffee is: ${0:0.00}", Math.Round(prices[j],2));
- }
- Console.WriteLine("Total: ${0:0.00}",Math.Round(totalPrice,2));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement