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