Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package MidExam.O6;
- import java.util.Scanner;
- public class O1BlackFlag {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int days = scanner.nextInt();
- int dailyPlunder = scanner.nextInt();
- double target = scanner.nextDouble();
- double sum = 0;
- for (int i = 1; i <= days; i++) {
- sum += dailyPlunder;
- if (i % 3 == 0) {
- sum += dailyPlunder * 0.5;
- }
- if (i % 5 == 0) {
- sum = sum * 0.7;
- }
- }
- if (sum >= target) {
- System.out.printf("Ahoy! %.2f plunder gained.", sum);
- } else {
- double percent = (sum / target) * 100;
- System.out.printf("Collected only %.2f%% of the plunder.", percent);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment