Advertisement
martinvalchev

Calories_Counter

Jan 28th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.11 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Calories_Counter
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int cout = int.Parse(Console.ReadLine());
  10.             int total = 0;
  11.             int countCheese = 0;
  12.             int countTomato = 0;
  13.             int countSalami = 0;
  14.             int countPepper = 0;
  15.  
  16.             for (int i = 1; i <= cout; i++)
  17.             {
  18.                 string product = Console.ReadLine().ToLower();
  19.                 if (product == "cheese")
  20.                 {
  21.                     countCheese++;
  22.                 }
  23.                 if (product == "tomato sauce")
  24.                 {
  25.                     countTomato++;
  26.                 }
  27.                 if (product == "salami")
  28.                 {
  29.                     countSalami++;
  30.                 }
  31.                 if (product == "pepper")
  32.                 {
  33.                     countPepper++;
  34.                 }
  35.             }
  36.             total = countCheese * 500 + countTomato * 150 + countSalami * 600 + countPepper * 50;
  37.             Console.WriteLine($"Total calories: {total}");
  38.  
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement