Advertisement
gospod1978

Middle Ex/Black Flag

Oct 30th, 2019
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.76 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. namespace fundamental14
  6. {
  7.     class MainClass
  8.     {
  9.         public static void Main()
  10.         {
  11.             int day = int.Parse(Console.ReadLine());
  12.             double pirate = double.Parse(Console.ReadLine());
  13.             double grab = double.Parse(Console.ReadLine());
  14.             double sum = 0;
  15.            
  16.             for (int i = 1; i <= day; i++)
  17.             {
  18.                
  19.                 sum += pirate;
  20.            
  21.                 if (i % 3 == 0)
  22.                 {
  23.                     sum += pirate / 2;
  24.                 }
  25.                 if (i % 5 == 0)
  26.                 {
  27.                    
  28.                     sum -= sum * 0.3;
  29.                 }
  30.             }
  31.            
  32.             if (sum >= grab)
  33.             {
  34.                 Console.WriteLine($"Ahoy! {sum:f2} plunder gained.");
  35.             }
  36.             else
  37.             {
  38.                 Console.WriteLine("Collected only {0:f2}% of the plunder.", (sum/grab)*100);
  39.             }
  40.            
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement