Advertisement
desislava_topuzakova

04. Cruise Games

May 1st, 2020
685
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.15 KB | None | 0 0
  1. using System;
  2. using System.Diagnostics;
  3.  
  4. namespace demo
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.  
  11.             string playerName = Console.ReadLine();
  12.             int countPlays = int.Parse(Console.ReadLine());
  13.  
  14.  
  15.             int countVolleyball = 0;
  16.             double pointsVolleyball = 0;
  17.  
  18.             int countTennis = 0;
  19.             double pointsTennis = 0;
  20.  
  21.             int countBadminton = 0;
  22.             double pointsBadminton = 0;
  23.  
  24.             for (int i = 1; i <= countPlays; i++)
  25.             {
  26.                 string gameName = Console.ReadLine();
  27.                 int points = int.Parse(Console.ReadLine());
  28.              
  29.  
  30.                 if (gameName == "volleyball")
  31.                 {
  32.                     countVolleyball++;
  33.                     double currentPoints = points + 0.07 * points;
  34.                     pointsVolleyball += currentPoints;
  35.  
  36.                 }
  37.                 else if (gameName == "tennis")
  38.                 {
  39.                     countTennis++;
  40.                     double currentPoints = points + 0.05 * points;
  41.                     pointsTennis += currentPoints;
  42.                 }
  43.                 else if(gameName == "badminton")
  44.                 {
  45.                     countBadminton++;
  46.                     double currentPoints = points + 0.02 * points;
  47.                     pointsBadminton += currentPoints;
  48.                 }
  49.             }
  50.  
  51.             double averageVolleyball = pointsVolleyball / countVolleyball;
  52.             double averageTennis = pointsTennis / countTennis;
  53.             double averageBadminton = pointsBadminton / countBadminton;
  54.  
  55.             double totalPoints = Math.Floor(pointsVolleyball + pointsTennis + pointsBadminton);
  56.  
  57.             if (averageVolleyball >= 75 && averageTennis >= 75 && averageBadminton >= 75) //печели
  58.             {
  59.                 Console.WriteLine($"Congratulations, {playerName}! You won the cruise games with {totalPoints} points.");
  60.             }
  61.             else
  62.             {
  63.                 Console.WriteLine($"Sorry, {playerName}, you lost. Your points are only {totalPoints}.");
  64.             }
  65.  
  66.         }
  67.     }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement