Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.*;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int days = Integer.parseInt(scanner.nextLine());
- double dailyBounty = Double.parseDouble(scanner.nextLine());
- double target = Double.parseDouble(scanner.nextLine());
- double booty = 0;
- for (int i = 1; i <= days; i++) {
- booty += dailyBounty;
- if (i % 3 == 0) {
- booty += (dailyBounty * 0.5);
- } else if (i % 5 == 0) {
- booty -= 0.3 * booty;
- }
- }
- if (booty >= target) {
- System.out.printf("Ahoy! %.2f plunder gained.", booty);
- } else {
- double procentPlunder = (booty / target) * 100;
- System.out.printf("Collected only %.2f%% of the plunder.", procentPlunder);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement