BubaLazi

08.CaloriesCalculator

Jun 2nd, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.37 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 SomeHomeworks
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var n = int.Parse(Console.ReadLine());
  14.            
  15.  
  16.             var cheese = 500;
  17.             var salami = 600;
  18.             var tomatoSauce = 150;
  19.             var pepper = 50;
  20.  
  21.             var totalCalories = 0;
  22.  
  23.             for ( int i = 0; i < n; i++)
  24.             {
  25.                 var ingredients = Console.ReadLine().ToLower();
  26.  
  27.                 if (ingredients == "cheese")
  28.                 {
  29.                     totalCalories = totalCalories + cheese;
  30.                 }
  31.                 else if (ingredients == "salami")
  32.                 {
  33.                     totalCalories = totalCalories + salami;
  34.                 }
  35.                 else if (ingredients == "tomato sauce")
  36.                 {
  37.                     totalCalories = totalCalories + tomatoSauce;
  38.                 }
  39.                 else if (ingredients == "pepper")
  40.                 {
  41.                     totalCalories = totalCalories + pepper;
  42.                 }
  43.                 else
  44.                 {
  45.                     continue;
  46.                 }
  47.  
  48.             }
  49.  
  50.             Console.WriteLine($"Total calories: { totalCalories}");
  51.  
  52.  
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment