Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Loops
- {
- class Program
- {
- static void Main(string[] args)
- {
- int children = int.Parse(Console.ReadLine());
- int lego = 0, puzzle = 0, robots = 0, monopoly = 0;
- for (int i = 0; i < children; i++)
- {
- string toy = Console.ReadLine();
- switch (toy)
- {
- case "lego": lego++; break;
- case "robot": robots++; break;
- case "monopoly": monopoly++; break;
- case "puzzle": puzzle++; break;
- }
- }
- double prLego = (lego * 100.0) / children;
- double prPuzzle = (puzzle * 100.0) / children;
- double prMono = (monopoly * 100.0) / children;
- double prRobot = (robots * 100.0) / children;
- Console.WriteLine($"Lego: {prLego:F2}%");
- Console.WriteLine($"Monopoly: {prMono:F2}%");
- Console.WriteLine($"Puzzles: {prPuzzle:F2}%");
- Console.WriteLine($"Robots: {prRobot:F2}%");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement