Advertisement
Spocoman

Cruise Games

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