Advertisement
Guest User

Untitled

a guest
Jun 1st, 2017
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Problem_8.Calories_Counter
  4. {
  5.    public class Program
  6.     {
  7.         public static void Main()
  8.         {
  9.             int n = int.Parse(Console.ReadLine());
  10.             int pepper = 0;
  11.             int salami = 0;
  12.             int tomatoSauce = 0;
  13.             int cheese = 0;
  14.  
  15.             for (int i = 1; i <= n; i++)
  16.             {
  17.                 string ingredients = Console.ReadLine().ToLower();
  18.                 if (ingredients=="cheese")
  19.                 {
  20.                     cheese += 500;
  21.                 }
  22.                 else if (ingredients == "salami")
  23.                 {
  24.                     salami += 600;
  25.                 }
  26.                 else if (ingredients == "pepper")
  27.                 {
  28.                     pepper += 50;
  29.                 }
  30.                 else if (ingredients=="tomato sauce")
  31.                 {
  32.                     tomatoSauce += 150;
  33.                 }
  34.             }
  35.             int total = cheese + pepper + salami + tomatoSauce;
  36.             Console.WriteLine($"Total calories: {total}");
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement