Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int clients = int.Parse(Console.ReadLine());
- string item = string.Empty;
- double purchasePrice = 0;
- int purchasedItems = 0;
- double totalPurchased = 0;
- double price = 0;
- int purchasedByClient = 0;
- for (int i = 1; i <= clients; i++)
- {
- purchasePrice = 0;
- purchasedByClient = 0;
- while ((item = Console.ReadLine()) != "Finish")
- {
- switch (item)
- {
- case "basket":
- price = 1.50;
- purchasePrice += price;
- purchasedItems++;
- purchasedByClient++;
- break;
- case "wreath":
- price = 3.80;
- purchasePrice += price;
- purchasedItems++;
- purchasedByClient++;
- break;
- case "chocolate bunny":
- price = 7.00;
- purchasePrice += price;
- purchasedItems++;
- purchasedByClient++;
- break;
- }
- }
- if (purchasedByClient % 2 == 0)
- {
- purchasePrice *= 0.80;
- }
- totalPurchased += purchasePrice;
- if (item == "Finish")
- {
- Console.WriteLine($"You purchased {purchasedByClient} items for {purchasePrice:f2} leva.");
- }
- }
- Console.WriteLine($"Average bill per client is: {(totalPurchased/(double)clients):f2} leva.");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement