veronikaaa86

08. Calories Counter

Jan 31st, 2018
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.60 KB | None | 0 0
  1. namespace Ex8_CaloriesCounter
  2. {
  3.     using System;
  4.     public class Program
  5.     {
  6.         public static void Main(string[] args)
  7.         {
  8.             int n = int.Parse(Console.ReadLine());
  9.  
  10.             int cal = 0;
  11.             int sum = 0;
  12.  
  13.             for (int i = 1; i <= n; i++)
  14.             {
  15.                 string ingrediends = Console.ReadLine();
  16.  
  17.                 if (ingrediends.Equals("cheese", StringComparison.InvariantCultureIgnoreCase))
  18.                 {
  19.                     cal = 500;
  20.                 }
  21.                 else if (ingrediends.Equals("toMatO sauce", StringComparison.InvariantCultureIgnoreCase))
  22.                 {
  23.                     cal = 150;
  24.                 }
  25.                 else if (ingrediends.Equals("salami", StringComparison.InvariantCultureIgnoreCase))
  26.                 {
  27.                     cal = 600;
  28.                 }
  29.                 else if (ingrediends.Equals("pepper", StringComparison.InvariantCultureIgnoreCase))
  30.                 {
  31.                     cal = 50;
  32.                 }
  33.  
  34.                 if (ingrediends.Equals("cheese", StringComparison.InvariantCultureIgnoreCase) ||
  35.                     ingrediends.Equals("toMatO sauce", StringComparison.InvariantCultureIgnoreCase) ||
  36.                     ingrediends.Equals("salami", StringComparison.InvariantCultureIgnoreCase) ||
  37.                     ingrediends.Equals("pepper", StringComparison.InvariantCultureIgnoreCase))
  38.                 {
  39.                     sum += cal;
  40.                 }
  41.                
  42.             }
  43.  
  44.             Console.WriteLine($"Total calories: {sum}");
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment