SHARE
TWEET

Untitled

a guest Dec 8th, 2019 102 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp1
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.             double n = double.Parse(Console.ReadLine());
  15.  
  16.             //Variables
  17.             double legoCount = 0;
  18.             double monopolyCount = 0;
  19.             double puzzleCount = 0;
  20.             double robotCount = 0;
  21.  
  22.             //Loop
  23.             for (int i = 0; i < n; i++)
  24.             {
  25.                 string typeGame = Console.ReadLine();
  26.  
  27.                 if (typeGame == "lego")
  28.                 {
  29.                     legoCount++;
  30.                 }
  31.                 else if (typeGame == "monopoly")
  32.                 {
  33.                     monopolyCount++;
  34.                 }
  35.                 else if (typeGame == "puzzle")
  36.                 {
  37.                     puzzleCount++;
  38.                 }
  39.                 else if (typeGame == "robot")
  40.                 {
  41.                     robotCount++;
  42.                 }
  43.  
  44.             }
  45.             //Calculations
  46.             double legoPercentage = legoCount / n * 100;
  47.             double monopolyPercentage = monopolyCount / n * 100;
  48.             double puzzlePercentage = puzzleCount / n * 100;
  49.             double robotPercentage = robotCount / n * 100;
  50.  
  51.             //Output
  52.             Console.WriteLine($"Lego: {legoPercentage:F2}%");
  53.             Console.WriteLine($"Monopoly: {monopolyPercentage:F2}%");
  54.             Console.WriteLine($"Puzzles: {puzzlePercentage:F2}%");
  55.             Console.WriteLine($"Robots: {robotPercentage:F2}%");
  56.         }
  57.     }
  58. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top