Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _06.BakingCompetition
- {
- class BakingCompetition
- {
- static void Main(string[] args)
- {
- int participantCount = int.Parse(Console.ReadLine());
- double totalCount = 0;
- double totalSum = 0.0;
- double priceCookies = 1.50;
- double priceCakes = 7.80;
- double priceWaffles = 2.30;
- for (int i = 0; i < participantCount; i++)
- {
- double cookiesCount = 0;
- double cakesCount = 0;
- double wafflesCount = 0;
- double cookiesSum = 0;
- double cakesSum = 0;
- double wafflesSum = 0;
- string participantName = Console.ReadLine();
- string sweetsType = Console.ReadLine();
- while (sweetsType != "Stop baking!")
- {
- int sweetieCount = int.Parse(Console.ReadLine());
- switch (sweetsType)
- {
- case "cookies":
- cookiesCount = sweetieCount;
- totalCount += cookiesCount;
- cookiesSum = cookiesCount * priceCookies;
- totalSum += cookiesSum;
- break;
- case "cakes":
- cakesCount = sweetieCount;
- totalCount += cakesCount;
- cakesSum = cakesCount * priceCakes;
- totalSum += cakesSum;
- break;
- case "waffles":
- wafflesCount = sweetieCount;
- totalCount += wafflesCount;
- wafflesSum = wafflesCount * priceWaffles;
- totalSum += wafflesSum;
- break;
- }
- sweetsType = Console.ReadLine();
- }
- Console.WriteLine($"{participantName}s baked {cookiesCount:f0} cookies, {cakesCount:f0} cakes and {wafflesCount:f0} waffles.");
- }
- Console.WriteLine($"All bakery sold: {totalCount}");
- Console.WriteLine($"Total sum for charity: {totalSum:f2} lv.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment