Advertisement
silvana1303

black flag

Jun 15th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.11 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5. using System.Threading;
  6.  
  7. namespace ConsoleApp1
  8. {
  9.     class Exam
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int days = int.Parse(Console.ReadLine());
  14.             int daily = int.Parse(Console.ReadLine());
  15.             int expected = int.Parse(Console.ReadLine());
  16.  
  17.             double sum = 0;
  18.  
  19.             for (int i = 1; i <= days; i++)
  20.             {
  21.                 sum += daily;
  22.  
  23.                 if (i % 3 == 0)
  24.                 {
  25.                     sum += daily * 0.50;
  26.                 }
  27.  
  28.                 if (i % 5 == 0)
  29.                 {
  30.                     sum -= (sum * 0.30);
  31.                 }
  32.          
  33.             }
  34.  
  35.             if (sum >= expected)
  36.             {
  37.                 Console.WriteLine($"Ahoy! {sum:f2} plunder gained.");
  38.             }
  39.             else
  40.             {
  41.                 double percentage = (sum / expected) * 100.0;
  42.                 Console.WriteLine($"Collected only {percentage:f2}% of the plunder.");
  43.             }
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement