Advertisement
silvana1303

experience gaining

Jun 14th, 2020
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.28 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5.  
  6. namespace ConsoleApp1
  7. {
  8.     class Exam
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             int experience = int.Parse(Console.ReadLine());
  13.             int battles = int.Parse(Console.ReadLine());
  14.             double sumExp = 0;
  15.             int count = 0;
  16.  
  17.             for (int i = 1; i <= battles; i++)
  18.             {
  19.                 double points = double.Parse(Console.ReadLine());
  20.  
  21.                 if (i % 3 == 0)
  22.                 {
  23.                     points *= 1.15;
  24.                 }
  25.                 if (i % 5 == 0)
  26.                 {
  27.                     points *= 0.90;
  28.                 }
  29.  
  30.                 sumExp += points;
  31.                 count = i;
  32.  
  33.                 if (sumExp >= experience)
  34.                 {
  35.                     break;
  36.                 }
  37.  
  38.             }
  39.  
  40.             if (sumExp >= experience)
  41.             {
  42.                 Console.WriteLine($"Player successfully collected his needed experience for {count} battles.");
  43.             }
  44.             else
  45.             {
  46.                 Console.WriteLine($"Player was not able to collect the needed experience, {experience - sumExp:f2} more needed.");
  47.             }
  48.  
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement