Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<iomanip>
- using namespace std;
- int main() {
- int days, dailyPlunder;
- cin >> days >> dailyPlunder;
- double expectedPlunder, totalPlunder = 0;
- cin >> expectedPlunder;
- for (int i = 1; i <= days; i++) {
- totalPlunder += dailyPlunder;
- if (i % 3 == 0) {
- totalPlunder += dailyPlunder * 0.5;
- }
- if (i % 5 == 0) {
- totalPlunder *= 0.7;
- }
- }
- if (totalPlunder >= expectedPlunder) {
- cout << "Ahoy! " << fixed << setprecision(2) << totalPlunder << " plunder gained.\n";
- }
- else {
- double percentage = totalPlunder / expectedPlunder * 100;
- cout << "Collected only " << fixed << setprecision(2) << percentage << "% of the plunder.\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement