Advertisement
Guest User

Untitled

a guest
Feb 29th, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace midprepare
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. int daysOfPlunder = int.Parse(Console.ReadLine());
  12. decimal dailyPlunder = decimal.Parse(Console.ReadLine());
  13. decimal expectedPlunder = decimal.Parse(Console.ReadLine());
  14. decimal totallPlunder = 0.0m;
  15. for (int i = 1; i <= daysOfPlunder; i++)
  16. {
  17. totallPlunder+=dailyPlunder;
  18. if (i % 3 == 0 && i != 0)
  19. {
  20. totallPlunder += dailyPlunder * 0.5m;
  21. }
  22. if (i % 5 == 0 && i!=0)
  23. {
  24. totallPlunder -= totallPlunder * 0.3m;
  25. }
  26.  
  27.  
  28.  
  29. }
  30.  
  31.  
  32. if (totallPlunder >= expectedPlunder)
  33. {
  34. Console.WriteLine($"Ahoy! {totallPlunder:f2} plunder gained.");
  35. }
  36. else
  37. {
  38. decimal percent = (((expectedPlunder - totallPlunder)/expectedPlunder) * 100);
  39. Console.WriteLine($"Collected only {(100-percent):f2}% of the plunder.");
  40.  
  41. }
  42. }
  43.  
  44.  
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement