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