Advertisement
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 ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- double n = double.Parse(Console.ReadLine());
- //Variables
- double legoCount = 0;
- double monopolyCount = 0;
- double puzzleCount = 0;
- double robotCount = 0;
- //Loop
- for (int i = 0; i < n; i++)
- {
- string typeGame = Console.ReadLine();
- if (typeGame == "lego")
- {
- legoCount++;
- }
- else if (typeGame == "monopoly")
- {
- monopolyCount++;
- }
- else if (typeGame == "puzzle")
- {
- puzzleCount++;
- }
- else if (typeGame == "robot")
- {
- robotCount++;
- }
- }
- //Calculations
- double legoPercentage = legoCount / n * 100;
- double monopolyPercentage = monopolyCount / n * 100;
- double puzzlePercentage = puzzleCount / n * 100;
- double robotPercentage = robotCount / n * 100;
- //Output
- Console.WriteLine($"Lego: {legoPercentage:F2}%");
- Console.WriteLine($"Monopoly: {monopolyPercentage:F2}%");
- Console.WriteLine($"Puzzles: {puzzlePercentage:F2}%");
- Console.WriteLine($"Robots: {robotPercentage:F2}%");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement