I was trying to finish some coding challenge where I have to update a menu when the program runs where a user enters a discount amount applied to all the prices.
using System;
using System.Collections.Generic;
class Program
{
static void Main(string[] args)
{
int discount = Convert.ToInt32(Console.ReadLine());
Dictionary<string, int> coffee = new Dictionary<string, int>();
coffee.Add("Americano", 50);
coffee.Add("Latte", 70);
coffee.Add("Flat White", 60);
coffee.Add("Espresso", 60);
coffee.Add("Cappuccino", 80);
coffee.Add("Mocha", 90);
foreach(string x in coffee.Keys)
{
coffee[x]-=coffee[x]*(discount/100)
}
I cannot change the prices with any iteration I tried. Help!
int discount = Convert.ToInt32(Console.ReadLine());
- unrelated: Never trust user input. Useint.TryParse
. – Fildor