Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace apps
- {
- class Program
- {
- static string Get() { return Console.ReadLine(); }
- static int GetInt() { return int.Parse(Console.ReadLine()); }
- static void Main()
- {
- int DAYS_AT_SEA = GetInt();
- int DAILY_PLUNDER = GetInt();
- double EXPECTED_PLUNDER = GetInt();
- double TOTAL_PLUNDER = 0;
- // calculate how much the pirates gather
- // each day they gather plunder
- // every 1/3 day they attack more ships and add more plunder = /2 daily_plunder
- // every 1/5 they lose 30% of total plunder
- // if plunder >= total -> "Ahoy! {totalPlunder} plunder gained."
- // else -> "Collected only {percentage}% of the plunder."
- for (int i =1; i<= DAYS_AT_SEA; i++)
- {
- if (i% 3 == 0)
- {
- double ADDITIONAL_PLUNDER = DAILY_PLUNDER / 2;
- TOTAL_PLUNDER += DAILY_PLUNDER + ADDITIONAL_PLUNDER;
- continue;
- }
- if (i % 5 == 0)
- {
- TOTAL_PLUNDER += DAILY_PLUNDER;
- TOTAL_PLUNDER *= 0.70;
- continue;
- }
- TOTAL_PLUNDER += DAILY_PLUNDER;
- }
- //---------------------------------------------------------
- if (TOTAL_PLUNDER>= EXPECTED_PLUNDER)
- {
- Console.WriteLine($"Ahoy! {TOTAL_PLUNDER:f2} plunder gained.");
- }
- else
- {
- double percentage = (TOTAL_PLUNDER*100)/EXPECTED_PLUNDER;
- Console.WriteLine($"Collected only { percentage:f2}% of the plunder.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement