Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Exam_11_12
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- int beveragesCount = 0;
- int sweetsCount = 0;
- int presentsCount = 0;
- int othersCount = 0;
- double beveragesTotalPrice = 0.0;
- double sweetsTotalPrice = 0.0;
- double presentsTotalPrice = 0.0;
- double othersTotalPrice = 0;
- for (int i = 0; i < n; i++)
- {
- string currentProduct = Console.ReadLine();
- double currentPrice = double.Parse(Console.ReadLine());
- double currentQuantity = double.Parse(Console.ReadLine());
- switch (currentProduct)
- {
- case "cola":
- case "wine":
- beveragesCount++;
- beveragesTotalPrice += currentPrice * currentQuantity;
- break;
- case "baklavichka":
- case "cupcake":
- sweetsCount++;
- sweetsTotalPrice += currentPrice * currentQuantity;
- break;
- case "flower":
- case "chocolates":
- case "book":
- presentsCount++;
- presentsTotalPrice += currentPrice * currentQuantity;
- break;
- default:
- othersCount++;
- othersTotalPrice += currentPrice * currentQuantity;
- break;
- }
- }
- double totalMoneySpend = beveragesTotalPrice + sweetsTotalPrice + presentsTotalPrice + othersTotalPrice;
- double sweetsPercentage = sweetsTotalPrice / totalMoneySpend * 100;
- double beveragesPercentage = beveragesTotalPrice / totalMoneySpend * 100;
- double presentsPercentage = presentsTotalPrice / totalMoneySpend * 100;
- double othersPercentage = othersTotalPrice / totalMoneySpend * 100;
- Console.WriteLine($"Total money spent: {totalMoneySpend:f2}");
- Console.WriteLine($"Money spent on: Sweets - {sweetsPercentage:f2}%; Beverages - {beveragesPercentage:f2}%; Presents - {presentsPercentage:f2}%;");
- Console.WriteLine($"Money spent on other products: {othersTotalPrice:f2} or {othersPercentage:f2}%");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment