petyaminkova91

Untitled

Oct 24th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _01_BlackFlag
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int totalDays = int.Parse(Console.ReadLine());
  10. int dailyPlunder = int.Parse(Console.ReadLine());
  11. double expectedPlunderInTheEnd = double.Parse(Console.ReadLine());
  12.  
  13. double totalPlunder = 0;
  14.  
  15. for (int i = 1; i <= totalDays; i++)
  16. {
  17. totalPlunder += dailyPlunder;
  18.  
  19. if (i % 3 == 0)
  20. {
  21. totalPlunder += 0.5 * dailyPlunder;
  22. }
  23. else if (i % 5 == 0)
  24. {
  25. totalPlunder *= 0.7;
  26. }
  27. }
  28.  
  29. if (totalPlunder >= expectedPlunderInTheEnd)
  30. {
  31. Console.WriteLine($"Ahoy! {totalPlunder:f2} plunder gained.");
  32. }
  33. else
  34. {
  35. double percent = totalPlunder * 100 / expectedPlunderInTheEnd;
  36.  
  37. Console.WriteLine($"Collected only {percent:f2}% of the plunder.");
  38. }
  39. }
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment