IvetValcheva

05. PC Game Shop

Apr 26th, 2021
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.43 KB | None | 0 0
  1. using System;
  2.  
  3. namespace OnTimeForTheExam
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int n = int.Parse(Console.ReadLine());
  10.  
  11.             double hearthstone = 0;
  12.             double fornite = 0;
  13.             double overwatch = 0;
  14.             double others = 0;
  15.  
  16.  
  17.             for (int i = 1; i <= n; i++)
  18.             {
  19.                 string gameName = Console.ReadLine();
  20.  
  21.                 if (gameName == "Hearthstone")
  22.                 {
  23.                     hearthstone++;
  24.                     //hearthstone+=1;
  25.                 }
  26.                 else if (gameName == "Fornite")
  27.                 {
  28.                     fornite++;
  29.                     //fornite = fornite + 1;
  30.  
  31.                 }
  32.                 else if (gameName == "Overwatch")
  33.                 {
  34.                     overwatch += 1;
  35.                     //overwatch++;
  36.  
  37.                 }
  38.                 else
  39.                 {
  40.                     others++;
  41.                 }
  42.             }
  43.  
  44.             double p1 = hearthstone / n * 100;
  45.             double p2 = fornite / n * 100;
  46.             double p3 = overwatch / n * 100;
  47.             double p4 = others / n * 100;
  48.  
  49.  
  50.             Console.WriteLine($"Hearthstone - {p1:F2}%");
  51.             Console.WriteLine($"Fornite - {p2:F2}%");
  52.             Console.WriteLine($"Overwatch - {p3:F2}%");
  53.             Console.WriteLine($"Others - {p4:F2}%");
  54.  
  55.         }
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment