Advertisement
koksibg

Calories_Counter

Sep 16th, 2017
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.84 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Calories_Counter
  4. {
  5.     class Calories_Counter
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int n = int.Parse(Console.ReadLine());
  10.             int countCheese = 0;
  11.             int countTomato = 0;
  12.             int countSalami = 0;
  13.             int countPepper = 0;
  14.             for (int i = 0; i < n; i++)
  15.             {
  16.                 string ingredient = Console.ReadLine().ToLower();
  17.                 if (ingredient == "cheese") countCheese++;
  18.                 if (ingredient == "tomato sauce") countTomato++;
  19.                 if (ingredient == "salami") countSalami++;
  20.                 if (ingredient == "pepper") countPepper++;
  21.             }
  22.             Console.WriteLine($"Total calories: {countCheese * 500 + countTomato * 150 + countSalami * 600 + countPepper * 50}");
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement