Advertisement
Guest User

Untitled

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