Advertisement
silvana1303

PC gamer shop

Apr 29th, 2020
834
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.48 KB | None | 0 0
  1. using System;
  2.  
  3. namespace exampreparation
  4.  
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             int gamesCount = int.Parse(Console.ReadLine());
  11.             string command = "";
  12.             int hearth = 0;
  13.             int fornite = 0;
  14.             int overwatch = 0;
  15.             int others = 0;
  16.  
  17.             for (int i = 0; i < gamesCount; i++)
  18.             {
  19.                  command = Console.ReadLine();
  20.  
  21.                 if (command == "Hearthstone")
  22.                 {
  23.                     hearth++;
  24.                 }
  25.                 else if (command == "Fornite")
  26.                 {
  27.                     fornite++;
  28.                 }
  29.                 else if (command == "Overwatch")
  30.                 {
  31.                     overwatch++;
  32.                 }
  33.                 else
  34.                 {
  35.                     others++;
  36.                 }
  37.             }
  38.  
  39.             double hearthPercent = (hearth * 1.0 / gamesCount) * 100.0;
  40.             double fornitePercent = (fornite * 1.0 / gamesCount) * 100.0;
  41.             double overwatchPercent = overwatch * 1.0 / gamesCount * 100.0;
  42.             double othersPercent = others * 1.0 / gamesCount * 100.0;
  43.  
  44.             Console.WriteLine($"Hearthstone - {hearthPercent:f2}%");
  45.             Console.WriteLine($"Fornite - {fornitePercent:f2}%");
  46.             Console.WriteLine($"Overwatch - {overwatchPercent:f2}%");
  47.             Console.WriteLine($"Others - {othersPercent:f2}%");
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement