Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _02b_ConditionalStatementsAndLoops_Exercises
- {
- class ConditionalStatementsAndLoopsEx
- {
- static void Main(string[] args)
- {
- int cheeseCalories = 0;
- int tomatoSauceCalories = 0;
- int salamiCalories = 0;
- int pepperCalories = 0;
- int numIngredients = int.Parse(Console.ReadLine());
- for (int i = 0; i < numIngredients; i++)
- {
- string ingredients = Console.ReadLine().ToLower();
- if (ingredients == "cheese")
- {
- cheeseCalories += 500;
- }
- else if (ingredients == "tomato sauce")
- {
- tomatoSauceCalories += 150;
- }
- else if (ingredients == "salami")
- {
- salamiCalories += 600;
- }
- else if (ingredients == "pepper")
- {
- pepperCalories += 50;
- }
- }
- Console.WriteLine($"Total calories: {cheeseCalories + tomatoSauceCalories + salamiCalories + pepperCalories}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment