using System.Collections.Generic;
private static Dictionary<string, decimal> cateringMenu = new Dictionary<string, decimal>()
{"Subway sandwich", 39.99M},
{"Cookie Platter", 19.99M},
public static void processCustomer()
var order = takeCateringOrder();
var Total = calculateTotal(order);
Console.WriteLine("TotaL\n", Total);
decimal payment = getPaymentFromCustomer(Total);
processPayment(Total, payment);
printReceipt(order, payment);
Console.WriteLine("Thank you for shopping at Subway!");
public static void printCateringMenu()
Console.WriteLine("Catering Menu:");
foreach (var product in cateringMenu)
Console.WriteLine("{0}: ${1:0.00}", product.Key, product.Value);
public static Dictionary<string, int> takeCateringOrder()
Dictionary<string, int> order = new Dictionary<string, int>();
foreach (var product in cateringMenu)
bool proceedToNextItem = false;
while (!proceedToNextItem)
Console.WriteLine("Purchase how many of {0} for {1:0.00} each?", product.Key, product.Value);
input = Console.ReadLine();
isValidQuantity = int.TryParse(input, out quantity);
Console.WriteLine("Invalid number input.");
else if (isValidQuantity && quantity == 0)
proceedToNextItem = true;
order.Add(product.Key, quantity);
proceedToNextItem = true;
public static decimal calculateTotal(Dictionary<string, int> order)
foreach (var item in order)
decimal costOfItems = itemQty * cateringMenu[item.Key];
public static decimal getPaymentFromCustomer(decimal total)
bool isValidPayment = false;
Console.WriteLine("Your total due is ${0:0.00}.", total);
var input = Console.ReadLine();
isValidPayment = decimal.TryParse(input, out payment);
Console.WriteLine("Invalid payment amount. Please try again.");
public static decimal processPayment(decimal total, decimal payment)
bool isPaymentEnough = false;
else if (payment < total)
"Payment ${0:0.00} is not enough for total ${1:0.00}"
payment = getPaymentFromCustomer(total);
change = payment + -total;
Console.WriteLine("Your change is ${0:0.00}.", change);
public static void printReceipt(Dictionary<string, int> order, decimal payment)
StringBuilder receipt = new StringBuilder("");
Console.WriteLine("Receipt");
foreach (var item in order)
item.Value * cateringMenu[item.Key]
var total = calculateTotal(order);
Console.WriteLine("Total: ${0:0.00}", total);
Console.WriteLine("Payment: ${0:0.00}", payment);
decimal change = processPayment(total, payment);
public static void Main()
Console.WriteLine("Enter your Employee type 1 for accountant , 2 for delivery person , 3 for servant");
val = Console.ReadLine();
choice = Convert.ToInt32(val);
Subway.processCustomer();
Console.WriteLine("Please deliver the food once ready");
Console.WriteLine("Please clean after customer leaves");
Console.WriteLine("Invalid input");