Problem solving Final Project C# 81
Hello ! I feel like I cheated in this last Project. I was stuck at the discount part of the problem. Was there any other way to apply the discount than using a cast to double ? :/ I had to look up on the web for a solution. At first, without the cast, only 0 was return for all the prices. Which makes sense to me because it's all int. But I would never had found otherwise, I think. namespace SoloLearn { class Program { static void Main(string[] args) { int discount = Convert.ToInt32(Console.ReadLine()); Dictionary<string, int> coffees = new Dictionary<string, int>(); coffees.Add("Americano", 50); coffees.Add("Latte", 70); coffees.Add("Flat White", 60); coffees.Add("Espresso", 60); coffees.Add("Cappuccino", 80); coffees.Add("Mocha", 90); //your code goes here foreach (string coffee in coffees.Keys.ToArray()) { coffees[coffee] -= (int)((double)coffees[coffee] / 100 * discount); Console.WriteLine(coffee + ": " + coffees[coffee]); } } } }