VelizarAvramov

08. Calories Counter

Nov 9th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.17 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _08._Calories_Counter
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int n = int.Parse(Console.ReadLine());
  10.  
  11.             int cheese = 500;
  12.             int tomatoSauce = 150;
  13.             int salami = 600;
  14.             int pepper = 50;
  15.             int totalCalories = 0;
  16.  
  17.             for (int i = 1; i <= n; i++)
  18.             {
  19.                 string ingredient = Console.ReadLine().ToLower();
  20.  
  21.                 switch (ingredient)
  22.                 {
  23.                     case "cheese":
  24.                         totalCalories += cheese;
  25.                         break;
  26.                     case "tomato sauce":
  27.                         totalCalories += tomatoSauce;
  28.                         break;
  29.                     case "salami":
  30.                         totalCalories += salami;
  31.                         break;
  32.                     case "pepper":
  33.                         totalCalories += pepper;
  34.                         break;
  35.  
  36.                     default:
  37.                         break;
  38.                 }
  39.             }
  40.             Console.WriteLine($"Total calories: {totalCalories}");
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment