Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace exampreparation
- {
- class exam
- {
- static void Main(string[] args)
- {
- int contestants = int.Parse(Console.ReadLine());
- int pastrySum = 0;
- double charitySum = 0.0;
- for (int i = 0; i < contestants; i++)
- {
- string name = Console.ReadLine();
- string command = Console.ReadLine();
- double price = 0.0;
- int cookies = 0;
- int cakes = 0;
- int waffles = 0;
- while (command != "Stop baking!")
- {
- string pastry = command;
- int pastryCount = int.Parse(Console.ReadLine());
- pastrySum += pastryCount;
- if (pastry == "cookies")
- {
- price = 1.50;
- cookies += pastryCount;
- }
- else if (pastry == "cakes")
- {
- price = 7.80;
- cakes += pastryCount;
- }
- else
- {
- price = 2.30;
- waffles += pastryCount;
- }
- charitySum += price * pastryCount;
- command = Console.ReadLine();
- }
- Console.WriteLine($"{name} baked {cookies} cookies, {cakes} cakes and {waffles} waffles.");
- }
- Console.WriteLine($"All bakery sold: {pastrySum}");
- Console.WriteLine($"Total sum for charity: {charitySum:f2} lv.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement