Advertisement
aggressiveviking

05.PCGameShop

Feb 26th, 2020
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.30 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _05.PCGameShop
  4. {
  5.     class PCGameShop
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int n = int.Parse(Console.ReadLine());
  10.  
  11.             int hearhstoneCnt = 0;
  12.             int forniteCnt = 0;
  13.             int overwatchCnt = 0;
  14.             int otherGamesCnt = 0;
  15.  
  16.             for (int i = 0; i < n; i++)
  17.             {
  18.                 string game = Console.ReadLine();
  19.                 switch (game)
  20.                 {
  21.                     case "Hearthstone": hearhstoneCnt++; break;
  22.                     case "Fornite": forniteCnt++; break;
  23.                     case "Overwatch": overwatchCnt++; break;
  24.                     default:
  25.                         otherGamesCnt++;
  26.                         break;
  27.                 }
  28.             }
  29.  
  30.             double heartstone = hearhstoneCnt * 1.0 / n * 100;
  31.             double fornite = forniteCnt * 1.0 / n * 100;
  32.             double overwatch = overwatchCnt * 1.0 / n * 100;
  33.             double others = otherGamesCnt * 1.0 / n * 100;
  34.            
  35.             Console.WriteLine($"Hearthstone - {heartstone:F2}%");
  36.             Console.WriteLine($"Fornite - {fornite:F2}%");
  37.             Console.WriteLine($"Overwatch - {overwatch:F2}%");
  38.             Console.WriteLine($"Others - {others:F2}%");
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement