Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 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 CaloriesCounter
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int n = int.Parse(Console.ReadLine());
  14. int calories = 0;
  15.  
  16. for(int x = 1; x <= n; x++)
  17. {
  18. string ingredient = Console.ReadLine().ToLower();
  19. if (n > 20 || ingredient.Length < 1 || ingredient.Length > 50)
  20. {
  21. Console.WriteLine("Error");
  22. }
  23.  
  24. if (ingredient == "cheese")
  25. {
  26. calories += 500;
  27. }
  28. if (ingredient == "tomato sauce")
  29. {
  30. calories += 150;
  31. }
  32. if (ingredient == "salami")
  33. {
  34. calories += 600;
  35. }
  36.  
  37. if (ingredient == "pepper")
  38. {
  39. calories += 50;
  40. }
  41. else
  42. {
  43. }
  44. }//for
  45.  
  46. Console.WriteLine($"Total calories: {calories}");
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement