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;
- int puzzle = 0;
- int robots = 0;
- int monopoly = 0;
- for (int i = 0; i < children; i++)
- {
- string toy = Console.ReadLine();
- if (toy == "lego")
- {
- lego++;
- }
- else if (toy == "puzzle")
- {
- puzzle++;
- }
- else if (toy == "robot")
- {
- robots++;
- }
- else if (toy == "monopoly")
- {
- monopoly++;
- }
- }
- 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