VelizarAvramov

08. Calories Counter

Nov 5th, 2018
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.43 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _08._Calories_Counter
  4. {
  5.     class CaloriesCounter
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             //You have to write a program, which counts the calories, which can be found in your pizza recipe. In your recipe, there
  10.             //are only four ingredients – cheese, tomato sauce, salami and pepper. Each ingredient contains a fixed amount of calories:
  11.             int number = int.Parse(Console.ReadLine());
  12.  
  13.             int cheese = 500;
  14.             int tomatoSauce = 150;
  15.             int salami = 600;
  16.             int papper = 50;
  17.             int totalCal = 0;
  18.  
  19.             for (int i = 0; i < number; i++)
  20.             {
  21.                 string ingredients = Console.ReadLine().ToLower();
  22.  
  23.                 switch (ingredients)
  24.                 {
  25.                     case "cheese":
  26.                         totalCal += cheese;
  27.                         break;
  28.                     case "tomato sauce":
  29.                         totalCal += tomatoSauce;
  30.                         break;
  31.                     case "salami":
  32.                         totalCal += salami;
  33.                         break;
  34.                     case "pepper":
  35.                         totalCal += papper;
  36.                         break;
  37.  
  38.                     default:
  39.                         break;
  40.                 }
  41.             }
  42.             Console.WriteLine($"Total calories: {totalCal}");
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment