Advertisement
Guest User

Untitled

a guest
Feb 2nd, 2023
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.99 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class E06BlackFlag1 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int countDays = Integer.parseInt(scanner.nextLine());
  8.         int plunderPerDay = Integer.parseInt(scanner.nextLine());
  9.         double expectedPlunder = Double.parseDouble(scanner.nextLine());
  10.  
  11.         double sumPlunder = 0;
  12.         double additional = plunderPerDay * 0.5;
  13.  
  14.         for (int days = 1; days <= countDays; days++) {
  15.             sumPlunder += plunderPerDay;
  16.  
  17.             if (days % 3 == 0) {
  18.                 sumPlunder += additional;
  19.             }
  20.  
  21.             if (days % 5 == 0) {
  22.                 sumPlunder *= 0.7;
  23.             }
  24.         }
  25.  
  26.         if (sumPlunder >= expectedPlunder) {
  27.             System.out.printf("Ahoy! %.2f plunder gained.", sumPlunder);
  28.         } else {
  29.             System.out.printf("Collected only %.2f%% of the plunder.", sumPlunder / expectedPlunder * 100);
  30.         }
  31.     }
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement