viraco4a

08. Calories Counter

May 22nd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _08_Calories_Counter
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int n = int.Parse(Console.ReadLine());
  14. Dictionary<string, int> ValidIngredients = new Dictionary<string, int>()
  15. {
  16. { "cheese", 500 }, { "tomato sauce", 150 }, { "salami", 600 }, { "pepper", 50 }
  17. };
  18. int calories = 0;
  19. for (int i = 0; i < n; i++)
  20. {
  21. string input = Console.ReadLine().ToLower();
  22. if (ValidIngredients.ContainsKey(input))
  23. {
  24. calories += ValidIngredients[input];
  25. }
  26. }
  27. Console.WriteLine($"Total calories: {calories}");
  28. }
  29. }
  30. }
Add Comment
Please, Sign In to add comment