Advertisement
Valantina

CruiseGames/Ex/27.07.2019

Jul 29th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.99 KB | None | 0 0
  1. using System;
  2.  
  3. namespace P05_CruiseGames
  4. {
  5.     class P05_CruiseGames
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int volleyballGames = 0;
  10.             int tennisGames = 0;
  11.             int badmintonGames = 0;
  12.  
  13.             double volleyballPoints = 0;
  14.             double tennisPoints = 0;
  15.             double badmintonPoints = 0;
  16.  
  17.             string player = Console.ReadLine();
  18.             int games = int.Parse(Console.ReadLine());
  19.  
  20.             for (int i = 0; i < games; i++)
  21.             {
  22.                 string gameName = Console.ReadLine();
  23.                 int points = int.Parse(Console.ReadLine());
  24.  
  25.                 switch (gameName)
  26.                 {
  27.                     case "volleyball":
  28.                         volleyballPoints += points * 1.07;
  29.                         volleyballGames++;
  30.                         break;
  31.                     case "tennis":
  32.                         tennisPoints += points * 1.05;
  33.                         tennisGames++;
  34.                         break;
  35.                     case "badminton":
  36.                         badmintonPoints += points * 1.02;
  37.                         badmintonGames++;
  38.                         break;
  39.                 }
  40.             }
  41.  
  42.             double volleyballAvgPoints = Math.Floor(volleyballPoints / volleyballGames);
  43.             double tennisAvgPoints = Math.Floor(tennisPoints / tennisGames);
  44.             double badmintonAvgPoints = Math.Floor(badmintonPoints / badmintonGames);
  45.             double totalPoints = Math.Floor(volleyballPoints + tennisPoints + badmintonPoints);
  46.  
  47.             if (volleyballAvgPoints >= 75 && tennisAvgPoints >= 75 && badmintonAvgPoints >= 75)
  48.             {
  49.                 Console.WriteLine($"Congratulations, {player}! You won the cruise games with {totalPoints} points.");
  50.             }
  51.             else
  52.             {
  53.                 Console.WriteLine($"Sorry, {player}, you lost. Your points are only {totalPoints}.");
  54.             }
  55.         }
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement