using System.Collections.Generic;
public decimal UnitPrice {get;set;}
public int Quantity {get;set;}
public static void Main()
var holdingItems = new List<Item>() {
new Item { UnitPrice = 150, Quantity = 2 },
new Item { UnitPrice = 50, Quantity = 3 },
new Item { UnitPrice = 25, Quantity = 6 },
var taxTotal = (decimal)42;
var remainingTax = (decimal)taxTotal;
var orderSubtotal = (decimal)600;
foreach (var item in holdingItems)
var extendedPrice = item.UnitPrice * item.Quantity;
var allocatedTax = taxTotal * (extendedPrice / orderSubtotal);
item.UnitPrice += allocatedTax / item.Quantity;
remainingTax -= allocatedTax;
Console.WriteLine(remainingTax);