I am attempting to write a program that asks the user for an item then displays the price using a dictionary. I need to loop the program so it repeats itself unless the user types "End" with any variation and it also needs to add the prices together for each item the user enters.
I have been stuck on this for several days any help would be awesome.
//dictionary using food and prices
Dictionary<string, double> FoodMenu = new Dictionary<string, double>();
//add food and prices
FoodMenu.Add("Baja Taco", 4.00);
FoodMenu.Add("Burrito", 7.50);
FoodMenu.Add("Bowl", 8.50);
FoodMenu.Add("Nachos", 11.00);
FoodMenu.Add("Quesadilla", 8.50);
FoodMenu.Add("Super Burrito", 8.50);
FoodMenu.Add("Super Quesadilla", 9.50);
FoodMenu.Add("Taco", 3.00);
FoodMenu.Add("Tortilla Salad", 8.00);
//get order
//food input string
string foodItem = getfooditem();
//use string
static string getfooditem()
{
Console.WriteLine("Item:");
string foodItem = Console.ReadLine();
return foodItem;
}
//check if key exists in food menu
string searchMenu = foodItem;
if (FoodMenu.ContainsKey(searchMenu))
{
Console.WriteLine($"Total: ${FoodMenu[searchMenu]}");
}
else
{
Console.WriteLine($"{searchMenu} does not exist in the menu.");
}